import sys

b,s=-1e10,1e10

eval(input())

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

 b,s=(b,r-s)[b<r-s],(s,r)[s>r]

print(b)

import sys

b,s=-1e10,1e10

eval(input())

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

 if b<r-s:b=r-s

 if s>r:s=r

print(b)

import sys

b, s = -1e10, 1e10
eval(input())
for r in map(int, sys.stdin.readlines()):
    b, s = (b, r - s)[b < r - s], (s, r)[s > r]
print(b)

import sys

b, s = -1e10, 1e10
eval(input())
for r in map(int, sys.stdin):
    if b < r - s:
        b = r - s
    if s > r:
        s = r
print(b)

-for r in map(int, sys.stdin.readlines()): -    b, s = (b, r - s)[b < r - s], (s, r)[s > r] +for r in map(int, sys.stdin): +    if b < r - s: +        b = r - s +    if s > r: +        s = r