a = input()
b = list(map(int, input().split()))
min = 100000
 
for i in range(len(b)):
  left = 0
  right = 0
  for j in range(i+1):
    left += b[j]
  for j in range(i+1, len(b)):
    right += b[j]
  if min > abs(left - right):
    min = abs(left - right)
    
print(min) a = input() a input() input b = list(map(int, input().split())) b list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split min = 100000 min 100000 for i in range(len(b)):
  left = 0
  right = 0
  for j in range(i+1):
    left += b[j]
  for j in range(i+1, len(b)):
    right += b[j]
  if min > abs(left - right):
    min = abs(left - right)
     i range(len(b)) range len(b) len b left = 0 left 0 right = 0 right 0 for j in range(i+1):
    left += b[j]
   j range(i+1) range i+1 i 1 left += b[j] left b[j] b j for j in range(i+1, len(b)):
    right += b[j]
   j range(i+1, len(b)) range i+1 i 1 len(b) len b right += b[j] right b[j] b j if min > abs(left - right):
    min = abs(left - right)
     min > abs(left - right) min abs(left - right) abs left - right left right min = abs(left - right) min abs(left - right) abs left - right left right print(min) print min min = 100000 100000 min left = 0 0 left right = 0 0 right a = input() input() a b = list(map(int, input().split())) list(map(int, input().split())) b min = abs(left - right) abs(left - right) min left += b[j] b[j] left right += b[j] b[j] right
a = input()
b = list(map(int, input().split()))
min = 100000
 
for i in range(len(b)):
  left = 0
  right = 0
  for j in range(i+1):
    left += b[j]
  for j in range(i+1, len(b)):
    right += b[j]
  if min > abs(left - right):
    min = abs(left - right)
    
print(min)