n = int(eval(input()))

min_r = int(eval(input()))

max_r = -1e10

for _ in range(n - 1):

    r = int(eval(input()))

    max_r = max(max_r, r - min_r)

    min_r = min(min_r, r)

print(max_r)

import sys

readline = sys.stdin.readline

n = int(eval(input()))

min_r = int(eval(input()))

max_r = -1e10

for _ in range(n - 1):

    r = int(readline())

    max_r = max(max_r, r - min_r)

    min_r = min(min_r, r)

print(max_r)



n = int(eval(input()))
min_r = int(eval(input()))
max_r = -1e10
for _ in range(n - 1):
    r = int(eval(input()))
    max_r = max(max_r, r - min_r)
    min_r = min(min_r, r)
print(max_r)

import sys

readline = sys.stdin.readline
n = int(eval(input()))
min_r = int(eval(input()))
max_r = -1e10
for _ in range(n - 1):
    r = int(readline())
    max_r = max(max_r, r - min_r)
    min_r = min(min_r, r)
print(max_r)

+import sys + +readline = sys.stdin.readline -    r = int(eval(input())) +    r = int(readline())