n = int(input())

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

# 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 ** 10 maxv - 10 ** 10 - 10 10 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 ** 10 - 10 ** 10 maxv minv = min(minv, r) min(minv, r) minv maxv = max(maxv, r - minv) max(maxv, r - minv) maxv minv = int(input()) int(input()) minv r = int(input()) int(input()) r n = int(input()) int(input()) n
n = int(input())

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

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

print(maxv)