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