N = int(eval(input()))

a = []

for i in range(N):

    a.append(int(eval(input())))



mins = [a[0]]

for i in range(1, N):

    mins.append(min(a[i], mins[i-1]))

    

mx = -10**12

for j in range(1, N):

    mx = max(mx, a[j] - mins[j-1])

print(mx)
N = int(eval(input()))



#R[0]

minv = int(eval(input()))

maxv = -10**12



#R[1..N-1]

for j in range(1, N):

    r = int(eval(input()))

    maxv = max(maxv, r - minv)

    minv = min(minv, r)

    

print(maxv)
N = int(eval(input()))
a = []
for i in range(N):
    a.append(int(eval(input())))
mins = [a[0]]
for i in range(1, N):
    mins.append(min(a[i], mins[i - 1]))
mx = -(10**12)
for j in range(1, N):
    mx = max(mx, a[j] - mins[j - 1])
print(mx)

N = int(eval(input()))
# R[0]
minv = int(eval(input()))
maxv = -(10**12)
# R[1..N-1]
for j in range(1, N):
    r = int(eval(input()))
    maxv = max(maxv, r - minv)
    minv = min(minv, r)
print(maxv)

-a = [] -for i in range(N): -    a.append(int(eval(input()))) -mins = [a[0]] -for i in range(1, N): -    mins.append(min(a[i], mins[i - 1])) -mx = -(10**12) +# R[0] +minv = int(eval(input())) +maxv = -(10**12) +# R[1..N-1] -    mx = max(mx, a[j] - mins[j - 1]) -print(mx) +    r = int(eval(input())) +    maxv = max(maxv, r - minv) +    minv = min(minv, r) +print(maxv)