#!/usr/bin/python


def main():
  times = int(input())
  min_rate = int(input())
  maxv = - 10 ** 9
  for _ in range(1, times):
    rate = int(input())

    if rate - min_rate > maxv:
      maxv = rate - min_rate

    if rate < min_rate:
      min_rate = rate

  print(maxv)
  return 0


if __name__ == '__main__':
  main() def main():
  times = int(input())
  min_rate = int(input())
  maxv = - 10 ** 9
  for _ in range(1, times):
    rate = int(input())

    if rate - min_rate > maxv:
      maxv = rate - min_rate

    if rate < min_rate:
      min_rate = rate

  print(maxv)
  return 0 main times = int(input()) times int(input()) int input() input min_rate = int(input()) min_rate int(input()) int input() input maxv = - 10 ** 9 maxv - 10 ** 9 - 10 9 for _ in range(1, times):
    rate = int(input())

    if rate - min_rate > maxv:
      maxv = rate - min_rate

    if rate < min_rate:
      min_rate = rate

   _ range(1, times) range 1 times rate = int(input()) rate int(input()) int input() input if rate - min_rate > maxv:
      maxv = rate - min_rate

     rate - min_rate > maxv rate - min_rate rate min_rate maxv maxv = rate - min_rate maxv rate - min_rate rate min_rate if rate < min_rate:
      min_rate = rate

   rate < min_rate rate min_rate min_rate = rate min_rate rate print(maxv) print maxv return 0 0 if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main def main():
  times = int(input())
  min_rate = int(input())
  maxv = - 10 ** 9
  for _ in range(1, times):
    rate = int(input())

    if rate - min_rate > maxv:
      maxv = rate - min_rate

    if rate < min_rate:
      min_rate = rate

  print(maxv)
  return 0 def main():
  times = int(input())
  min_rate = int(input())
  maxv = - 10 ** 9
  for _ in range(1, times):
    rate = int(input())

    if rate - min_rate > maxv:
      maxv = rate - min_rate

    if rate < min_rate:
      min_rate = rate

  print(maxv)
  return 0 main
#!/usr/bin/python


def main():
  times = int(input())
  min_rate = int(input())
  maxv = - 10 ** 9
  for _ in range(1, times):
    rate = int(input())

    if rate - min_rate > maxv:
      maxv = rate - min_rate

    if rate < min_rate:
      min_rate = rate

  print(maxv)
  return 0


if __name__ == '__main__':
  main()