N = int(input())
W = [int(w) for w in input().split()]
S1 = 0
S2 = 0
ans = []
for i in range(N):
  S2 = sum(W) - S1
  ans.append(abs(S2 - S1))
  S1 = 0
  S2 = 0
  for j in range(i + 1):
    S1 += W[j]
print(min(ans)) N = int(input()) N int(input()) int input() input int(w) for w in input().split() for w in input().split() w input().split() ().split () input split for w in input().split() int(w) int w W = [int(w) for w in input().split()] W [int(w) for w in input().split()] S1 = 0 S1 0 S2 = 0 S2 0 ans = [] ans [] for i in range(N):
  S2 = sum(W) - S1
  ans.append(abs(S2 - S1))
  S1 = 0
  S2 = 0
  for j in range(i + 1):
    S1 += W[j] i range(N) range N S2 = sum(W) - S1 S2 sum(W) - S1 sum(W) sum W S1 ans.append(abs(S2 - S1)) ans.append ans append abs(S2 - S1) abs S2 - S1 S2 S1 S1 = 0 S1 0 S2 = 0 S2 0 for j in range(i + 1):
    S1 += W[j] j range(i + 1) range i + 1 i 1 S1 += W[j] S1 W[j] W j print(min(ans)) print min(ans) min ans W = [int(w) for w in input().split()] [int(w) for w in input().split()] W N = int(input()) int(input()) N S2 = 0 0 S2 S2 = sum(W) - S1 sum(W) - S1 S2 S1 = 0 0 S1 ans = [] [] ans S1 = 0 0 S1 S1 += W[j] W[j] S1 S2 = 0 0 S2
N = int(input())
W = [int(w) for w in input().split()]
S1 = 0
S2 = 0
ans = []
for i in range(N):
  S2 = sum(W) - S1
  ans.append(abs(S2 - S1))
  S1 = 0
  S2 = 0
  for j in range(i + 1):
    S1 += W[j]
print(min(ans))