N = int(eval(input()))

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

s_right = [0] * (N + 1)

s_left = [0] * (N + 1)

for i in range(N):

    s_left[i + 1] = s_left[i] + a[i]

    s_right[i + 1] = s_right[i] + a[N - 1 - i]

ans = float('Inf')

for i in range(1, N):

    #print(ans)

    if ans > abs(s_left[i] - s_right[N - i]):

        ans = abs(s_left[i] - s_right[N - i])

print(ans)

N = int(eval(input()))

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

s = [0] * (N + 1)

for i in range(N):

    s[i + 1] = s[i] + a[i]

ans = float('Inf')

for i in range(1, N):

    #print(ans)

    kouho = abs(s[i] - ((s[-1]) - s[i]))

    if ans > kouho:

        ans = kouho

    #ans = min(ans, kouho)

print(ans)

N = int(eval(input()))
a = list(map(int, input().split()))
s_right = [0] * (N + 1)
s_left = [0] * (N + 1)
for i in range(N):
    s_left[i + 1] = s_left[i] + a[i]
    s_right[i + 1] = s_right[i] + a[N - 1 - i]
ans = float("Inf")
for i in range(1, N):
    # print(ans)
    if ans > abs(s_left[i] - s_right[N - i]):
        ans = abs(s_left[i] - s_right[N - i])
print(ans)

N = int(eval(input()))
a = list(map(int, input().split()))
s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = s[i] + a[i]
ans = float("Inf")
for i in range(1, N):
    # print(ans)
    kouho = abs(s[i] - ((s[-1]) - s[i]))
    if ans > kouho:
        ans = kouho
    # ans = min(ans, kouho)
print(ans)

-s_right = [0] * (N + 1) -s_left = [0] * (N + 1) +s = [0] * (N + 1) -    s_left[i + 1] = s_left[i] + a[i] -    s_right[i + 1] = s_right[i] + a[N - 1 - i] +    s[i + 1] = s[i] + a[i] -    if ans > abs(s_left[i] - s_right[N - i]): -        ans = abs(s_left[i] - s_right[N - i]) +    kouho = abs(s[i] - ((s[-1]) - s[i])) +    if ans > kouho: +        ans = kouho +    # ans = min(ans, kouho)