length = STDIN.gets.to_s.to_i
r = Array.new

for i in 0..length - 1 do
    r.push(STDIN.gets.to_s.to_i)
end

max_p = r[1] - r[0]

for i in 0..length - 2 do
    for j in (i + 1)..length - 1 do
        if (r[j] - r[i]) > max_p then
            max_p = (r[j] - r[i])
        end
    end
end

p max_p