def find_the_remainder(p)
  length = p.length
  output = []
  for i in 0..(length-2)
    for j in 0..(length-1)
      next if  j<= i
    result = (p[j]) - (p[i])
    output.push(result)
    end
  end
  return output
end

n = gets.chomp.to_i
input_values = []
n.times do
  input_value = gets.chomp.to_i
  input_values.push(input_value)
end

puts find_the_remainder(input_values).max