uses crt;
var i,n,t,tg,j:longint;
a:array[1..100] of longint;
begin
clrscr;
readln(n);
for i:=1 to n do read(a[i]);
t:=0;
for i:=1 to n do if a[i]<0 then t:=t+a[i];
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then begin tg:=a[i];
a[i]:=a[j];
a[j]:=t;
end;
write(a[2]);
readln
end.