import sys



n = int(eval(input()))

minv = int(eval(input()))

v = int(eval(input()))

maxv = v-minv

if v < minv: minv = v



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



n = int(eval(input()))

minv = int(eval(input()))

maxv = -1000000000



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

  if maxv < r-minv < 0:

    maxv = r-minv

    minv = r

  elif maxv < r-minv:

    maxv = r-minv

  elif r-minv < 0:

    minv = r



print(maxv)
import sys

n = int(eval(input()))
minv = int(eval(input()))
v = int(eval(input()))
maxv = v - minv
if v < minv:
    minv = v
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

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

-v = int(eval(input())) -maxv = v - minv -if v < minv: -    minv = v +maxv = -1000000000 -    m = r - minv -    if maxv < m < 0: -        maxv = m +    if maxv < r - minv < 0: +        maxv = r - minv -    elif maxv < m: -        maxv = m -    elif m < 0: +    elif maxv < r - minv: +        maxv = r - minv +    elif r - minv < 0: