program uspon;
var n, i, v, sv, u, nu : integer;

begin
    readln(n); read(v);
    u := v; nu := 0;
    for i := 2 to n do begin
        sv := v;
        read(v);
        if v <= sv then begin
            if nu < (sv-u) then
                nu := sv-u;
            u := v;
        end;
    end;
    if nu < (v-u) then
        nu := v-u;
    writeln(nu);
end.