ary_original = []
ary_answers  = []
tempmaxi = 0
maxi = 0
n, *ary_original = $<.map(&:to_i)
c=0

while premaxi < n
  max = 0
  min = 1E9+10

  for i in premaxi...n
    if max < a[i]
      max  = a[i]
      maxi = i
    end
  end

  for i in premaxi..maxi
    if min > a[i] then min=a[i] end
  end

  if max == min then c += 1 end

  ary_answers << max - min
  premaxi = maxi + 1
end

if c == n
  max = - (1E9 + 10)

  for i in 0..n-2
    x = a[i+1] - a[i]
    if max < x then max = x end
  end

  puts max
else

  puts ary_answers.max
end

