N = int(input())

#R[0]
minv = int(input())
maxv = -10**12

#R[1..N-1]
for j in range(1, N):
    r = int(input())
    maxv = max(maxv, r - minv)
    minv = min(minv, r)
    
print(maxv) N = int(input()) N int(input()) int input() input minv = int(input()) minv int(input()) int input() input maxv = -10**12 maxv -10**12 -10 12 for j in range(1, N):
    r = int(input())
    maxv = max(maxv, r - minv)
    minv = min(minv, r)
     j range(1, N) range 1 N r = int(input()) r int(input()) int input() input maxv = max(maxv, r - minv) maxv max(maxv, r - minv) max maxv r - minv r minv minv = min(minv, r) minv min(minv, r) min minv r print(maxv) print maxv maxv = -10**12 -10**12 maxv minv = int(input()) int(input()) minv r = int(input()) int(input()) r maxv = max(maxv, r - minv) max(maxv, r - minv) maxv N = int(input()) int(input()) N minv = min(minv, r) min(minv, r) minv
N = int(input())

#R[0]
minv = int(input())
maxv = -10**12

#R[1..N-1]
for j in range(1, N):
    r = int(input())
    maxv = max(maxv, r - minv)
    minv = min(minv, r)
    
print(maxv)