import itertools
n = int(input())
R = [int(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 itertools 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)] ret = -(10 ** 9) ret -(10 ** 9) 10 ** 9 10 9 mn = R[0] mn R[0] R 0 for r in itertools.islice(R, 1, len(R)):
    ret = max(ret, r - mn)
    mn = min(mn, r) r itertools.islice(R, 1, len(R)) itertools.islice itertools islice R 1 len(R) len R ret = max(ret, r - mn) ret max(ret, r - mn) max ret r - mn r mn mn = min(mn, r) mn min(mn, r) min mn r print(ret) print ret n = int(input()) int(input()) n R = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] R ret = -(10 ** 9) -(10 ** 9) ret ret = max(ret, r - mn) max(ret, r - mn) ret mn = min(mn, r) min(mn, r) mn mn = R[0] R[0] mn
import itertools
n = int(input())
R = [int(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)