n=int(input())
w=list(map(int,input().split()))
sum=int(0)
for i in range(n):
  sum+=w[i]
dif=sum
for i in range(n):
  psum=int(0)
  for j in range(i):
    psum+=w[j]
  dif=min(dif,abs(psum-(sum-psum)))
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 sum=int(0) sum int(0) int 0 for i in range(n):
  sum+=w[i] i range(n) range n sum+=w[i] sum w[i] w i dif=sum dif sum for i in range(n):
  psum=int(0)
  for j in range(i):
    psum+=w[j]
  dif=min(dif,abs(psum-(sum-psum))) i range(n) range n psum=int(0) psum int(0) int 0 for j in range(i):
    psum+=w[j]
   j range(i) range i psum+=w[j] psum w[j] w j dif=min(dif,abs(psum-(sum-psum))) dif min(dif,abs(psum-(sum-psum))) min dif abs(psum-(sum-psum)) abs psum-(sum-psum) psum sum-psum sum psum print(dif) print dif dif=min(dif,abs(psum-(sum-psum))) min(dif,abs(psum-(sum-psum))) dif n=int(input()) int(input()) n dif=sum sum dif psum=int(0) int(0) psum w=list(map(int,input().split())) list(map(int,input().split())) w psum+=w[j] w[j] psum sum+=w[i] w[i] sum sum=int(0) int(0) sum
n=int(input())
w=list(map(int,input().split()))
sum=int(0)
for i in range(n):
  sum+=w[i]
dif=sum
for i in range(n):
  psum=int(0)
  for j in range(i):
    psum+=w[j]
  dif=min(dif,abs(psum-(sum-psum)))
print(dif)
