n = STDIN.gets.to_i
unless (2 <= n and n <= 200000)
  p ("erro: 0 <= n <= 200000")
  exit
end

xs = (0...n.to_i).map {|x| STDIN.gets.to_i }
min = nil
diff_max = -1000000001

xs.each {|x, i|
  if (i == 0)
    min = x
  else
    diff = x - min
    if (diff > diff_max)
      diff_max = diff
    end
    if (x < min)
      min = x
    end
  end
}

puts diff_max