import sys
 
l = sys.stdin.readlines()
minv = int(l[1])
maxv = -1000000000

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

for r in map(int,l[2:]):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)