n = gets.chomp.to_i

nums = Array.new
n.times do |i|
   nums.push gets.chomp.to_i
end

nums = nums.reverse
max = -999999999
for j in 0..(n-2) do

   k = j + 1

   for m in k..(n-1) do

      diff = nums[j] - nums[m]
      if diff > max
         max = diff
      end

   end

end

puts max