n = int(input())
minv = int(input())
maxv = -1000000000

for r in [int(input())  for i in range(1,n)]:
  maxv = max(maxv,r-minv)
  minv = min(r,minv)

print(maxv) n = int(input()) n int(input()) int input() input minv = int(input()) minv int(input()) int input() input maxv = -1000000000 maxv -1000000000 for r in [int(input())  for i in range(1,n)]:
  maxv = max(maxv,r-minv)
  minv = min(r,minv) r [int(input())  for i in range(1,n)] maxv = max(maxv,r-minv) maxv max(maxv,r-minv) max maxv r-minv r minv minv = min(r,minv) minv min(r,minv) min r minv print(maxv) print maxv minv = int(input()) int(input()) minv minv = min(r,minv) min(r,minv) minv maxv = -1000000000 -1000000000 maxv maxv = max(maxv,r-minv) max(maxv,r-minv) maxv n = int(input()) int(input()) n
n = int(input())
minv = int(input())
maxv = -1000000000

for r in [int(input())  for i in range(1,n)]:
  maxv = max(maxv,r-minv)
  minv = min(r,minv)

print(maxv)