n = int(eval(input()))

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

s = sum(li)

sum_li = []

for i,l in enumerate(li):

    if i == 0:

        sum_li.append(l)

        continue

    sum_li.append(sum_li[-1]+l)

all_li = []

for ii,ss in enumerate(sum_li):

    if ii == len(sum_li)-1:

        break

    all_li.append(abs(s-2*ss))

#print(all_li)

print((min(all_li)))
n = int(eval(input()))

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

s = sum(li)

sum_li = []

left = 0

right = s

for i,l in enumerate(li):

    if i == len(li)-1:

        break

    left += l

    right -= l

    sum_li.append(abs(left-right))

print((min(sum_li)))
n = int(eval(input()))
li = list(map(int, input().split()))
s = sum(li)
sum_li = []
for i, l in enumerate(li):
    if i == 0:
        sum_li.append(l)
        continue
    sum_li.append(sum_li[-1] + l)
all_li = []
for ii, ss in enumerate(sum_li):
    if ii == len(sum_li) - 1:
        break
    all_li.append(abs(s - 2 * ss))
# print(all_li)
print((min(all_li)))

n = int(eval(input()))
li = list(map(int, input().split()))
s = sum(li)
sum_li = []
left = 0
right = s
for i, l in enumerate(li):
    if i == len(li) - 1:
        break
    left += l
    right -= l
    sum_li.append(abs(left - right))
print((min(sum_li)))

+left = 0 +right = s -    if i == 0: -        sum_li.append(l) -        continue -    sum_li.append(sum_li[-1] + l) -all_li = [] -for ii, ss in enumerate(sum_li): -    if ii == len(sum_li) - 1: +    if i == len(li) - 1: -    all_li.append(abs(s - 2 * ss)) -# print(all_li) -print((min(all_li))) +    left += l +    right -= l +    sum_li.append(abs(left - right)) +print((min(sum_li)))