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