program ladder;
Uses Math;
const
    MAXN = 1000000;

var
    N, i, diff  : longint;
    C     : array[0..MAXN-1] of longint;

begin
{
    uncomment the following lines if you want to read/write from files
    assign(input,  'input.txt');  reset(input);
    assign(output, 'output.txt'); rewrite(output);
}

    readln(N);
    for i:=0 to N-1 do
        read(C[i]);
    readln();
    diff:=C[0];
    for i:=1 to N-1 do
            if C[i+1]>C[i] then diff:=max(diff, C[i+1-C[i]]);
    writeln(diff); { print result }
end.
