s_max = -float('inf')

s = 0

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

	r = int(eval(input()))

	if i:

		d = r - prev

		s = max(s, 0) + d

		s_max = max(s, s_max)

	prev = r

print(s_max)

s_max = -float('inf')

s = 0

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

	r = int(eval(input()))

	if i:

		s = max(s, 0) + r - prev

		s_max = max(s, s_max)

	prev = r

print(s_max)

s_max = -float("inf")
s = 0
for i in range(int(eval(input()))):
    r = int(eval(input()))
    if i:
        d = r - prev
        s = max(s, 0) + d
        s_max = max(s, s_max)
    prev = r
print(s_max)

s_max = -float("inf")
s = 0
for i in range(int(eval(input()))):
    r = int(eval(input()))
    if i:
        s = max(s, 0) + r - prev
        s_max = max(s, s_max)
    prev = r
print(s_max)

-        d = r - prev -        s = max(s, 0) + d +        s = max(s, 0) + r - prev