N=int(input())
W=list(map(int, input().split()))
 
sum1,sum2=0,0
ans=0
dif=1000
 
for i in range(N):
    sum1=sum(W[0:i])
    sum2=sum(W[i:])
    now = abs(sum1-sum2)
    if dif > now:
        dif =now
 
print(dif) 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 sum1,sum2=0,0 sum1 0 sum2 0 ans=0 ans 0 dif=1000 dif 1000 for i in range(N):
    sum1=sum(W[0:i])
    sum2=sum(W[i:])
    now = abs(sum1-sum2)
    if dif > now:
        dif =now
  i range(N) range N sum1=sum(W[0:i]) sum1 sum(W[0:i]) sum W[0:i] W 0:i 0 i sum2=sum(W[i:]) sum2 sum(W[i:]) sum W[i:] W i: i now = abs(sum1-sum2) now abs(sum1-sum2) abs sum1-sum2 sum1 sum2 if dif > now:
        dif =now
  dif > now dif now dif =now dif now print(dif) print dif sum1,sum2=0,0 0 sum1 dif=1000 1000 dif N=int(input()) int(input()) N sum2=0,0 0 sum2 dif =now now dif sum1=sum(W[0:i]) sum(W[0:i]) sum1 ans=0 0 ans sum2=sum(W[i:]) sum(W[i:]) sum2 now = abs(sum1-sum2) abs(sum1-sum2) now W=list(map(int, input().split())) list(map(int, input().split())) W
N=int(input())
W=list(map(int, input().split()))
 
sum1,sum2=0,0
ans=0
dif=1000
 
for i in range(N):
    sum1=sum(W[0:i])
    sum2=sum(W[i:])
    now = abs(sum1-sum2)
    if dif > now:
        dif =now
 
print(dif)