n=int(eval(input()))

l= list((int(x) for x in input().split()))

beg=end=i=0

n-=1

while(i<=n):

	if(beg>end):

		end+=l[n]

		n-=1

	else:

		beg+=l[i]

		i+=1

print((abs(end-beg)))
n = int(eval(input()))

arr = list(map(int, input().split()))



i = 0

j = n-1

sumL =0

sumR = 0

while(i <= j):

    if(sumL < sumR):

        sumL += arr[i]

        i +=1

    else:

        sumR += arr[j]

        j -=1



print((abs(sumL - sumR)))

n = int(eval(input()))
l = list((int(x) for x in input().split()))
beg = end = i = 0
n -= 1
while i <= n:
    if beg > end:
        end += l[n]
        n -= 1
    else:
        beg += l[i]
        i += 1
print((abs(end - beg)))

n = int(eval(input()))
arr = list(map(int, input().split()))
i = 0
j = n - 1
sumL = 0
sumR = 0
while i <= j:
    if sumL < sumR:
        sumL += arr[i]
        i += 1
    else:
        sumR += arr[j]
        j -= 1
print((abs(sumL - sumR)))

-l = list((int(x) for x in input().split())) -beg = end = i = 0 -n -= 1 -while i <= n: -    if beg > end: -        end += l[n] -        n -= 1 +arr = list(map(int, input().split())) +i = 0 +j = n - 1 +sumL = 0 +sumR = 0 +while i <= j: +    if sumL < sumR: +        sumL += arr[i] +        i += 1 -        beg += l[i] -        i += 1 -print((abs(end - beg))) +        sumR += arr[j] +        j -= 1 +print((abs(sumL - sumR)))