n = int( eval(input( )) )



mi = int( eval(input( )) )

profit = 0 - 1000000000



for i in range( n-1 ):

	num = int( eval(input( )) )

	

	diff = num - mi

	if profit < diff:

		profit = diff



	if num < mi:

		mi = num



print( profit )

		
n = int( input( ) )



mi = int( input( ) )

profit = 0 - 1000000000

n -= 1

i = 0

while i < n:

	num = int( input( ) )

	

	diff = num - mi

	if profit < diff:

		profit = diff



	if num < mi:

		mi = num

	i += 1



print( profit )
n = int(eval(input()))
mi = int(eval(input()))
profit = 0 - 1000000000
for i in range(n - 1):
    num = int(eval(input()))
    diff = num - mi
    if profit < diff:
        profit = diff
    if num < mi:
        mi = num
print(profit)

n = int(input())
mi = int(input())
profit = 0 - 1000000000
n -= 1
i = 0
while i < n:
    num = int(input())
    diff = num - mi
    if profit < diff:
        profit = diff
    if num < mi:
        mi = num
    i += 1
print(profit)

-n = int(eval(input())) -mi = int(eval(input())) +n = int(input()) +mi = int(input()) -for i in range(n - 1): -    num = int(eval(input())) +n -= 1 +i = 0 +while i < n: +    num = int(input()) +    i += 1