N=int(input())
W=list(map(int,input().split()))
t=sum(W)
a=[]
for x in range(N):
  s1=0
  for y in range(x+1):
    s1 += W[y]
  a.append(abs(t-2*s1))
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 t=sum(W) t sum(W) sum W a=[] a [] for x in range(N):
  s1=0
  for y in range(x+1):
    s1 += W[y]
  a.append(abs(t-2*s1)) x range(N) range N s1=0 s1 0 for y in range(x+1):
    s1 += W[y]
   y range(x+1) range x+1 x 1 s1 += W[y] s1 W[y] W y a.append(abs(t-2*s1)) a.append a append abs(t-2*s1) abs t-2*s1 t 2*s1 2 s1 print(min(a)) print min(a) min a W=list(map(int,input().split())) list(map(int,input().split())) W s1 += W[y] W[y] s1 t=sum(W) sum(W) t N=int(input()) int(input()) N a=[] [] a s1=0 0 s1
N=int(input())
W=list(map(int,input().split()))
t=sum(W)
a=[]
for x in range(N):
  s1=0
  for y in range(x+1):
    s1 += W[y]
  a.append(abs(t-2*s1))
print(min(a))