N = int(input())
W = list(map(int, input().split()))
 
# O(N^2)で解いても間に合う
m = 10**10
for i in range(1, N):
  a, b = 0, 0
  for j in range(i):
    a += W[j]
  for j in range(i, N):
    b += W[j]
  m = min(m, abs(a-b))
print(m) 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 m = 10**10 m 10**10 10 10 for i in range(1, N):
  a, b = 0, 0
  for j in range(i):
    a += W[j]
  for j in range(i, N):
    b += W[j]
  m = min(m, abs(a-b)) i range(1, N) range 1 N a, b = 0, 0 a 0 b 0 for j in range(i):
    a += W[j]
   j range(i) range i a += W[j] a W[j] W j for j in range(i, N):
    b += W[j]
   j range(i, N) range i N b += W[j] b W[j] W j m = min(m, abs(a-b)) m min(m, abs(a-b)) min m abs(a-b) abs a-b a b print(m) print m a, b = 0, 0 0 a b = 0, 0 0 b b += W[j] W[j] b a += W[j] W[j] a m = min(m, abs(a-b)) min(m, abs(a-b)) m m = 10**10 10**10 m N = int(input()) int(input()) N W = list(map(int, input().split())) list(map(int, input().split())) W
N = int(input())
W = list(map(int, input().split()))
 
# O(N^2)で解いても間に合う
m = 10**10
for i in range(1, N):
  a, b = 0, 0
  for j in range(i):
    a += W[j]
  for j in range(i, N):
    b += W[j]
  m = min(m, abs(a-b))
print(m)