n=int(input())
w=list(map(int,input().split()))

a=[]

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

a=[]

for i in range(0,n):
    ans=(w[:i])
    a.append(abs(2*sum(ans)-sum(w)))
        
print(min(a))