n = int(eval(input()))

R = (int(eval(input())) for _ in range(n))

ret = -(10 ** 9)

mn = next(R)

for r in R:

    ret = max(ret, r - mn)

    mn = min(mn, r)

print(ret)
import itertools

n = int(eval(input()))

R = [int(eval(input())) for _ in range(n)]

ret = -(10 ** 9)

mn = R[0]

for r in itertools.islice(R, 1, len(R)):

    ret = max(ret, r - mn)

    mn = min(mn, r)

print(ret)
n = int(eval(input()))
R = (int(eval(input())) for _ in range(n))
ret = -(10**9)
mn = next(R)
for r in R:
    ret = max(ret, r - mn)
    mn = min(mn, r)
print(ret)

import itertools

n = int(eval(input()))
R = [int(eval(input())) for _ in range(n)]
ret = -(10**9)
mn = R[0]
for r in itertools.islice(R, 1, len(R)):
    ret = max(ret, r - mn)
    mn = min(mn, r)
print(ret)

+import itertools + -R = (int(eval(input())) for _ in range(n)) +R = [int(eval(input())) for _ in range(n)] -mn = next(R) -for r in R: +mn = R[0] +for r in itertools.islice(R, 1, len(R)):