n=gets.to_i
s=Array.new
c=Array.new
m=0
for i in 1..n do
    v=gets.to_i
    s.push(v)
    if    i==1 then next
    elsif i==2 then m=s[1]-s[0]
    else
          m=[m,s[i-1]-c.min].max
    end
    c.push(v)
end
p m