N = int(input())
W = list(map(int, input().split()))
S = sum(W)
m = S
for i in range(1, N):
  T = sum(W[:i])
  m = min(m, abs(T-(S-T)))
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 S = sum(W) S sum(W) sum W m = S m S for i in range(1, N):
  T = sum(W[:i])
  m = min(m, abs(T-(S-T))) i range(1, N) range 1 N T = sum(W[:i]) T sum(W[:i]) sum W[:i] W :i i m = min(m, abs(T-(S-T))) m min(m, abs(T-(S-T))) min m abs(T-(S-T)) abs T-(S-T) T S-T S T print(m) print m N = int(input()) int(input()) N S = sum(W) sum(W) S m = min(m, abs(T-(S-T))) min(m, abs(T-(S-T))) m W = list(map(int, input().split())) list(map(int, input().split())) W m = S S m T = sum(W[:i]) sum(W[:i]) T
N = int(input())
W = list(map(int, input().split()))
S = sum(W)
m = S
for i in range(1, N):
  T = sum(W[:i])
  m = min(m, abs(T-(S-T)))
print(m)