N = int(eval(input()))

M = -1000000000

L = int(eval(input()))

for i in range(1,N):

    C = int(eval(input()))

    M = max(C - L, M)

    L = min(C, L)

print(M)
import sys

eval(input())

a,b=-1e11,1e11

for i in map(int,sys.stdin.readlines()):

  a=max(a,i-b)

  b=min(i,b)

print(a)
N = int(eval(input()))
M = -1000000000
L = int(eval(input()))
for i in range(1, N):
    C = int(eval(input()))
    M = max(C - L, M)
    L = min(C, L)
print(M)

import sys

eval(input())
a, b = -1e11, 1e11
for i in map(int, sys.stdin.readlines()):
    a = max(a, i - b)
    b = min(i, b)
print(a)

-N = int(eval(input())) -M = -1000000000 -L = int(eval(input())) -for i in range(1, N): -    C = int(eval(input())) -    M = max(C - L, M) -    L = min(C, L) -print(M) +import sys + +eval(input()) +a, b = -1e11, 1e11 +for i in map(int, sys.stdin.readlines()): +    a = max(a, i - b) +    b = min(i, b) +print(a)