n=int(input())
w=list(map(int,input().split()))
s=[0]
for i in w:
    s.append(s[-1]+i)
ss=s[-1]
ans=10**20
for i in range(n+1):
    ans=min(ans,abs((ss-s[i])-s[i]))
print(ans) n=int(input()) n int(input()) int input() input w=list(map(int,input().split())) w list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s=[0] s [0] 0 for i in w:
    s.append(s[-1]+i) i w s.append(s[-1]+i) s.append s append s[-1]+i s[-1] s -1 i ss=s[-1] ss s[-1] s -1 ans=10**20 ans 10**20 10 20 for i in range(n+1):
    ans=min(ans,abs((ss-s[i])-s[i])) i range(n+1) range n+1 n 1 ans=min(ans,abs((ss-s[i])-s[i])) ans min(ans,abs((ss-s[i])-s[i])) min ans abs((ss-s[i])-s[i]) abs (ss-s[i])-s[i] ss-s[i] ss s[i] s i s[i] s i print(ans) print ans s=[0] [0] s n=int(input()) int(input()) n ss=s[-1] s[-1] ss ans=min(ans,abs((ss-s[i])-s[i])) min(ans,abs((ss-s[i])-s[i])) ans w=list(map(int,input().split())) list(map(int,input().split())) w ans=10**20 10**20 ans
n=int(input())
w=list(map(int,input().split()))
s=[0]
for i in w:
    s.append(s[-1]+i)
ss=s[-1]
ans=10**20
for i in range(n+1):
    ans=min(ans,abs((ss-s[i])-s[i]))
print(ans)