n = gets.chomp.to_i
r = n.times.map{ gets.chomp.to_i }

max = r.last - r.first
(r.size - 1).downto(1) do |i|
  (i - 1).downto(0) do |j|
    diff = r[i] - r[j]
    max = diff if max < diff
  end
end

puts max