Var n, i, k, max: integer; begin readln(n); for i := 1 to n do begin readln(k); if ((k < 0) and ((max = 0) or (k > max))) then max := k; end; writeln(max); end.