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

for i in range(n):
  s1=0
  s2=0
  for j in range(i):
    s1=s1+w[j]
  for k in range(i, n):
    s2=s2+w[k]
  ans=min(ans, max(s1, s2)- min(s1, s2))
  
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 ans=10000 ans 10000 for i in range(n):
  s1=0
  s2=0
  for j in range(i):
    s1=s1+w[j]
  for k in range(i, n):
    s2=s2+w[k]
  ans=min(ans, max(s1, s2)- min(s1, s2))
   i range(n) range n s1=0 s1 0 s2=0 s2 0 for j in range(i):
    s1=s1+w[j]
   j range(i) range i s1=s1+w[j] s1 s1+w[j] s1 w[j] w j for k in range(i, n):
    s2=s2+w[k]
   k range(i, n) range i n s2=s2+w[k] s2 s2+w[k] s2 w[k] w k ans=min(ans, max(s1, s2)- min(s1, s2)) ans min(ans, max(s1, s2)- min(s1, s2)) min ans max(s1, s2)- min(s1, s2) max(s1, s2) max s1 s2 min(s1, s2) min s1 s2 print(ans) print ans w=list(map(int,input().split())) list(map(int,input().split())) w ans=10000 10000 ans n=int(input()) int(input()) n s1=0 0 s1 s1=s1+w[j] s1+w[j] s1 ans=min(ans, max(s1, s2)- min(s1, s2)) min(ans, max(s1, s2)- min(s1, s2)) ans s2=0 0 s2 s2=s2+w[k] s2+w[k] s2
n=int(input())
w=list(map(int,input().split()))
ans=10000

for i in range(n):
  s1=0
  s2=0
  for j in range(i):
    s1=s1+w[j]
  for k in range(i, n):
    s2=s2+w[k]
  ans=min(ans, max(s1, s2)- min(s1, s2))
  
print(ans)