b,s=-1e10,1e10

for _ in range(int(eval(input()))):

 r=int(eval(input()))

 b,s=max(b,r-s),min(s,r)

print(b)

import sys

b,s=-1e10,1e10

eval(input())

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

 b,s=max(b,r-s),min(s,r)

print(b)

b, s = -1e10, 1e10
for _ in range(int(eval(input()))):
    r = int(eval(input()))
    b, s = max(b, r - s), min(s, r)
print(b)

import sys

b, s = -1e10, 1e10
eval(input())
for r in map(int, sys.stdin.readlines()):
    b, s = max(b, r - s), min(s, r)
print(b)

+import sys + -for _ in range(int(eval(input()))): -    r = int(eval(input())) +eval(input()) +for r in map(int, sys.stdin.readlines()):