raw_input = []
while (n = gets.to_i) != 0 do
  raw_input << n
end
input = raw_input[1..-1]
result = input.map.with_index do |val, index|
  input[index+1..-1].map do |i|
    i - val
  end.max
end.reject(&:nil?)
p result.max

