def max(a, b)
  if a.nil?
    b
  else
    (a > b) ? a : b
  end
end

n = gets.to_i

data = Array.new
for i in 1..n do
  data[i - 1] = gets.to_i
end

mx = nil

for i in 1..n-1 do
  for j in i + 1 .. n do
    mx = max(mx, data[j - 1] - data[i - 1])
  end
end

puts mx