n = gets.chomp.to_i
ns = []
bresult = []
n.times do |i|
  ns.push(gets.to_i)
end
ns.reverse!
n.times do |i|
  n-i.times do |ii|
    bresult.push(ns[i-1]-ns[ii-1])
  end
end
puts bresult.sort[bresult.size-1]

