import sys

n = int(input())
minv = int(input())
v = int(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 sys n = int(input()) n int(input()) int input() input minv = int(input()) minv int(input()) int input() input v = int(input()) v int(input()) int input() input maxv = v-minv maxv v-minv v minv if v < minv: minv = v v < minv v minv 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 r map(int,sys.stdin.readlines()) map int sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines m = r-minv m r-minv r minv if maxv < m < 0:
    maxv = m
    minv = r
  elif maxv < m:
    maxv = m
  elif m < 0:
    minv = r maxv < m < 0 maxv < m maxv m 0 maxv = m maxv m minv = r minv r elif maxv < m:
    maxv = m
   maxv < m maxv m maxv = m maxv m elif m < 0:
    minv = r m < 0 m 0 minv = r minv r print(maxv) print maxv minv = r r minv n = int(input()) int(input()) n minv = r r minv maxv = m m maxv m = r-minv r-minv m maxv = v-minv v-minv maxv v = int(input()) int(input()) v maxv = m m maxv minv = int(input()) int(input()) minv
import sys

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