n = int(input())
a = list(map(int,input().split()))
s = []
tmp = 0
for i in range(n-1):
    tmp += a[i]
    s.append(tmp)

ans = 10**9
total = sum(a)
for i in s:
    ans = min(ans, abs(total-2*i))
print(ans) n = int(input()) n int(input()) int input() input a = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s = [] s [] tmp = 0 tmp 0 for i in range(n-1):
    tmp += a[i]
    s.append(tmp) i range(n-1) range n-1 n 1 tmp += a[i] tmp a[i] a i s.append(tmp) s.append s append tmp ans = 10**9 ans 10**9 10 9 total = sum(a) total sum(a) sum a for i in s:
    ans = min(ans, abs(total-2*i)) i s ans = min(ans, abs(total-2*i)) ans min(ans, abs(total-2*i)) min ans abs(total-2*i) abs total-2*i total 2*i 2 i print(ans) print ans a = list(map(int,input().split())) list(map(int,input().split())) a s = [] [] s tmp += a[i] a[i] tmp ans = 10**9 10**9 ans tmp = 0 0 tmp n = int(input()) int(input()) n ans = min(ans, abs(total-2*i)) min(ans, abs(total-2*i)) ans total = sum(a) sum(a) total
n = int(input())
a = list(map(int,input().split()))
s = []
tmp = 0
for i in range(n-1):
    tmp += a[i]
    s.append(tmp)

ans = 10**9
total = sum(a)
for i in s:
    ans = min(ans, abs(total-2*i))
print(ans)