gets
min=10 ** 9 + 1
output = gets.chomp.to_i - min

while line = gets
  target = line.chomp.to_i
  value = target - min
  output = value if value > output
  min = target if target < min
end

puts output