data = list()

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

    data.append(int(eval(input())))



max_diff = -1000000000

min_data = data[0]

for value in data[1:] :

    max_diff = max(max_diff, value - min_data)

    min_data = min(min_data, value)



print(max_diff) 

data = []

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

    data.append(int(eval(input())))

    

max_diff = -1000000000

min_data = data[0]



for value in data[1:] :

    max_diff = max(max_diff, value - min_data)

    min_data = min(min_data, value)



print(max_diff)

data = list()
for i in range(int(eval(input()))):
    data.append(int(eval(input())))
max_diff = -1000000000
min_data = data[0]
for value in data[1:]:
    max_diff = max(max_diff, value - min_data)
    min_data = min(min_data, value)
print(max_diff)

data = []
for _ in range(int(eval(input()))):
    data.append(int(eval(input())))
max_diff = -1000000000
min_data = data[0]
for value in data[1:]:
    max_diff = max(max_diff, value - min_data)
    min_data = min(min_data, value)
print(max_diff)

-data = list() -for i in range(int(eval(input()))): +data = [] +for _ in range(int(eval(input()))):