n = int(eval(input()))

minv = int(eval(input()))

maxv = -1000000000



for i in range(1,n):

  r = int(eval(input()))

  maxv = max(maxv,r-minv)

  minv = min(r,minv)



print(maxv)
n = int(eval(input()))

minv = int(eval(input()))

maxv = -1000000000



for i in range(1,n):

  r = int(eval(input()))

  m = r-minv

  if maxv < m < 0:

    maxv = m

    minv = r

  elif maxv < m:

    maxv = m

  elif m < 0:

    minv = r



print(maxv)
n = int(eval(input()))
minv = int(eval(input()))
maxv = -1000000000
for i in range(1, n):
    r = int(eval(input()))
    maxv = max(maxv, r - minv)
    minv = min(r, minv)
print(maxv)

n = int(eval(input()))
minv = int(eval(input()))
maxv = -1000000000
for i in range(1, n):
    r = int(eval(input()))
    m = r - minv
    if maxv < m < 0:
        maxv = m
        minv = r
    elif maxv < m:
        maxv = m
    elif m < 0:
        minv = r
print(maxv)

-    maxv = max(maxv, r - minv) -    minv = min(r, minv) +    m = r - minv +    if maxv < m < 0: +        maxv = m +        minv = r +    elif maxv < m: +        maxv = m +    elif m < 0: +        minv = r