n = gets.to_i
min = last = gets.to_i
max = 0
profits = []
(n-1).times{
  current = gets.to_i
  if (current <= last)
    profits<<(current-last)
    min = current if (current < min)
    max = 0
  end
  max = current if (current > last)
  profits<<(max-min) if (max != 0)
  last = current
}
puts profits.uniq!.max