n = STDIN.gets.to_i
nums = []
n.times do |i|
  nums << STDIN.gets.to_i
end
max = -Float::INFINITY
(0..(n-2)).each do |i|
  ((i+1)..(n-1)).each do |j|
    diff = nums[j] - nums[i]
    if diff > max
      max = diff
    end
  end
end
puts max