N = int(eval(input()))

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

ruiseki = [0]*(N+1)

total = 0

now = 10**20

sa = 0

now_2 = 0

for i in range(N):

  total += A[i]

  ruiseki[i+1] = total

for i in range(1,len(ruiseki)-1):

  snuke = ruiseki[i]-ruiseki[0]

  arai = ruiseki[N]-ruiseki[i]

  now_2 = abs(snuke-arai)

  now = min(now,now_2)

print(now)

N = int(eval(input()))

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

ruisekiwa = [0]*(N+1)

now = 0

minimum = 10**10

for i in range(N):

  now += A[i]

  ruisekiwa[i+1] = now

for i in range(N-1):

  snuke = ruisekiwa[i+1]

  arai = ruisekiwa[N]-snuke

  K = abs(snuke-arai)

  if K < minimum:

    minimum = K

print(minimum)
N = int(eval(input()))
A = list(map(int, input().split()))
ruiseki = [0] * (N + 1)
total = 0
now = 10**20
sa = 0
now_2 = 0
for i in range(N):
    total += A[i]
    ruiseki[i + 1] = total
for i in range(1, len(ruiseki) - 1):
    snuke = ruiseki[i] - ruiseki[0]
    arai = ruiseki[N] - ruiseki[i]
    now_2 = abs(snuke - arai)
    now = min(now, now_2)
print(now)

N = int(eval(input()))
A = list(map(int, input().split()))
ruisekiwa = [0] * (N + 1)
now = 0
minimum = 10**10
for i in range(N):
    now += A[i]
    ruisekiwa[i + 1] = now
for i in range(N - 1):
    snuke = ruisekiwa[i + 1]
    arai = ruisekiwa[N] - snuke
    K = abs(snuke - arai)
    if K < minimum:
        minimum = K
print(minimum)

-ruiseki = [0] * (N + 1) -total = 0 -now = 10**20 -sa = 0 -now_2 = 0 +ruisekiwa = [0] * (N + 1) +now = 0 +minimum = 10**10 -    total += A[i] -    ruiseki[i + 1] = total -for i in range(1, len(ruiseki) - 1): -    snuke = ruiseki[i] - ruiseki[0] -    arai = ruiseki[N] - ruiseki[i] -    now_2 = abs(snuke - arai) -    now = min(now, now_2) -print(now) +    now += A[i] +    ruisekiwa[i + 1] = now +for i in range(N - 1): +    snuke = ruisekiwa[i + 1] +    arai = ruisekiwa[N] - snuke +    K = abs(snuke - arai) +    if K < minimum: +        minimum = K +print(minimum)