n = int(eval(input()))

minv = int(eval(input()))

maxv = -1000000000



for i in range(1,n):

  r = int(eval(input()))

  m = r-minv

  if maxv < m < 0:

    maxv = m

    minv = r

  elif maxv < m:

    maxv = m

  elif m < 0:

    minv = r



print(maxv)
import sys



n = int(eval(input()))

minv = int(eval(input()))

maxv = -1000000000



for r in map(int,sys.stdin.readlines()):

  m = r-minv

  if maxv < m < 0:

    maxv = m

    minv = r

  elif maxv < m:

    maxv = m

  elif m < 0:

    minv = r



print(maxv)
n = int(eval(input()))
minv = int(eval(input()))
maxv = -1000000000
for i in range(1, n):
    r = int(eval(input()))
    m = r - minv
    if maxv < m < 0:
        maxv = m
        minv = r
    elif maxv < m:
        maxv = m
    elif m < 0:
        minv = r
print(maxv)

import sys

n = int(eval(input()))
minv = int(eval(input()))
maxv = -1000000000
for r in map(int, sys.stdin.readlines()):
    m = r - minv
    if maxv < m < 0:
        maxv = m
        minv = r
    elif maxv < m:
        maxv = m
    elif m < 0:
        minv = r
print(maxv)

+import sys + -for i in range(1, n): -    r = int(eval(input())) +for r in map(int, sys.stdin.readlines()):