n = gets(chomp:true).to_i

r = []
n.times do
  r << gets(chomp:true).to_i
end

maxv = r[1] - r[0]

for j in 1...n
  for i in 0...j
     dif = r[j]-r[i]
      maxv = dif if dif > maxv
   end
end

puts maxv
