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