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