def inpl(): return input().split()



n = int(eval(input()))

a = list(map(int, inpl()))

sa = sum(a)

b = [a[0]]

for i in range(1, n - 1):

    b.append(a[i] + b[i - 1])



ans = float('inf')

for x in b:

    ans = min(ans, abs(sa - 2 * x))

print(ans)
n = int(eval(input()))

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



ret = 10 ** 15



s = 0

t = sum(a)

a.pop()  # 最後の要素は取れない

for x in a:

    s += x

    t -= x

    ret = min(ret, abs(s - t))



print(ret)

def inpl():
    return input().split()


n = int(eval(input()))
a = list(map(int, inpl()))
sa = sum(a)
b = [a[0]]
for i in range(1, n - 1):
    b.append(a[i] + b[i - 1])
ans = float("inf")
for x in b:
    ans = min(ans, abs(sa - 2 * x))
print(ans)

n = int(eval(input()))
(*a,) = list(map(int, input().split()))
ret = 10**15
s = 0
t = sum(a)
a.pop()  # 最後の要素は取れない
for x in a:
    s += x
    t -= x
    ret = min(ret, abs(s - t))
print(ret)

-def inpl(): -    return input().split() - - -a = list(map(int, inpl())) -sa = sum(a) -b = [a[0]] -for i in range(1, n - 1): -    b.append(a[i] + b[i - 1]) -ans = float("inf") -for x in b: -    ans = min(ans, abs(sa - 2 * x)) -print(ans) +(*a,) = list(map(int, input().split())) +ret = 10**15 +s = 0 +t = sum(a) +a.pop()  # 最後の要素は取れない +for x in a: +    s += x +    t -= x +    ret = min(ret, abs(s - t)) +print(ret)