N=int(input())
W=list(map(int,input().split()))


total=sum(W)
ans=10**10

for i in range(N):
    ans=min(ans,abs(2*sum(W[0:i])-total))
    
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 total=sum(W) total sum(W) sum W ans=10**10 ans 10**10 10 10 for i in range(N):
    ans=min(ans,abs(2*sum(W[0:i])-total))
     i range(N) range N ans=min(ans,abs(2*sum(W[0:i])-total)) ans min(ans,abs(2*sum(W[0:i])-total)) min ans abs(2*sum(W[0:i])-total) abs 2*sum(W[0:i])-total 2*sum(W[0:i]) 2 sum(W[0:i]) sum W[0:i] W 0:i 0 i total print(ans) print ans N=int(input()) int(input()) N ans=min(ans,abs(2*sum(W[0:i])-total)) min(ans,abs(2*sum(W[0:i])-total)) ans W=list(map(int,input().split())) list(map(int,input().split())) W total=sum(W) sum(W) total ans=10**10 10**10 ans
N=int(input())
W=list(map(int,input().split()))


total=sum(W)
ans=10**10

for i in range(N):
    ans=min(ans,abs(2*sum(W[0:i])-total))
    
print(ans)

