N = int(input())
R = [int(input()) for _ in range(N)]
maxv = -2000000000
minv = R[0]

for i in range(1,N):
  maxv = max([maxv, R[i] - minv ])
  minv = min([minv, R[i]])

print(maxv)
 N = int(input()) N int(input()) int input() input int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input R = [int(input()) for _ in range(N)] R [int(input()) for _ in range(N)] maxv = -2000000000 maxv -2000000000 minv = R[0] minv R[0] R 0 for i in range(1,N):
  maxv = max([maxv, R[i] - minv ])
  minv = min([minv, R[i]]) i range(1,N) range 1 N maxv = max([maxv, R[i] - minv ]) maxv max([maxv, R[i] - minv ]) max [maxv, R[i] - minv ] maxv R[i] - minv R[i] R i minv minv = min([minv, R[i]]) minv min([minv, R[i]]) min [minv, R[i]] minv R[i] R i print(maxv) print maxv N = int(input()) int(input()) N minv = R[0] R[0] minv maxv = -2000000000 -2000000000 maxv maxv = max([maxv, R[i] - minv ]) max([maxv, R[i] - minv ]) maxv R = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] R minv = min([minv, R[i]]) min([minv, R[i]]) minv
N = int(input())
R = [int(input()) for _ in range(N)]
maxv = -2000000000
minv = R[0]

for i in range(1,N):
  maxv = max([maxv, R[i] - minv ])
  minv = min([minv, R[i]])

print(maxv)

