n=int(input())
w=list(map(int,input().split()))
s=[0]*n
for i in range(n-1):
  s[i+1]=s[i]+w[i]
ans=sum(w)
for i in range(1,n):
  ans=min(ans,abs((sum(w)-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]*n s [0]*n [0] 0 n for i in range(n-1):
  s[i+1]=s[i]+w[i] i range(n-1) range n-1 n 1 s[i+1]=s[i]+w[i] s[i+1] s i+1 i 1 s[i]+w[i] s[i] s i w[i] w i ans=sum(w) ans sum(w) sum w for i in range(1,n):
  ans=min(ans,abs((sum(w)-s[i])-s[i])) i range(1,n) range 1 n ans=min(ans,abs((sum(w)-s[i])-s[i])) ans min(ans,abs((sum(w)-s[i])-s[i])) min ans abs((sum(w)-s[i])-s[i]) abs (sum(w)-s[i])-s[i] sum(w)-s[i] sum(w) sum w s[i] s i s[i] s i print(ans) print ans s=[0]*n [0]*n s ans=sum(w) sum(w) ans n=int(input()) int(input()) n ans=min(ans,abs((sum(w)-s[i])-s[i])) min(ans,abs((sum(w)-s[i])-s[i])) ans w=list(map(int,input().split())) list(map(int,input().split())) w
n=int(input())
w=list(map(int,input().split()))
s=[0]*n
for i in range(n-1):
  s[i+1]=s[i]+w[i]
ans=sum(w)
for i in range(1,n):
  ans=min(ans,abs((sum(w)-s[i])-s[i]))
print(ans)