n = gets.to_i
a = Array.new(n)
n.times do |i|
  a[i] = gets.to_i
end

max = -100000000
for i in 0..n-2 do
  for j in i+1..n-1 do
    if a[j]-a[i] > max
      max = a[j]-a[i]
    end
  end
end
puts max
