N = int(eval(input()))



purchase_price = int(eval(input()))

profit = -2000000000

for _ in range(N-1):

    price = int(eval(input()))

    profit = max(profit, (price-purchase_price))

    purchase_price = min(price, purchase_price)



print(profit)

N = int(eval(input()))

r1 = int(eval(input()))

r2 = int(eval(input()))

R = [int(eval(input())) for i in range(N-2)]



res = r2 - r1

min_r = min(r1, r2)



for r in R:

  res = max(res, r - min_r)

  min_r = min(min_r, r)



print(res)



N = int(eval(input()))
purchase_price = int(eval(input()))
profit = -2000000000
for _ in range(N - 1):
    price = int(eval(input()))
    profit = max(profit, (price - purchase_price))
    purchase_price = min(price, purchase_price)
print(profit)

N = int(eval(input()))
r1 = int(eval(input()))
r2 = int(eval(input()))
R = [int(eval(input())) for i in range(N - 2)]
res = r2 - r1
min_r = min(r1, r2)
for r in R:
    res = max(res, r - min_r)
    min_r = min(min_r, r)
print(res)

-purchase_price = int(eval(input())) -profit = -2000000000 -for _ in range(N - 1): -    price = int(eval(input())) -    profit = max(profit, (price - purchase_price)) -    purchase_price = min(price, purchase_price) -print(profit) +r1 = int(eval(input())) +r2 = int(eval(input())) +R = [int(eval(input())) for i in range(N - 2)] +res = r2 - r1 +min_r = min(r1, r2) +for r in R: +    res = max(res, r - min_r) +    min_r = min(min_r, r) +print(res)