n = gets.to_i
rs = []
n.times do
  rs << gets.to_i
end

max = -10 ** 9
rs.length.times do |i|
  break if i == rs.length - 1
  (i+1..rs.length-1).each do |j|
    max = rs[j] - rs[i] if rs[j] - rs[i] > max
  end
end

puts max