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