N = int(input())
W = list(map(int, input().split()))

S = sum(W)

ans = S
c = 0
for i in range(N):
  c += W[i]
  S -= W[i]
  s = abs(S - c)
  ans = min(ans, s)

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

S = sum(W)

ans = S
c = 0
for i in range(N):
  c += W[i]
  S -= W[i]
  s = abs(S - c)
  ans = min(ans, s)

print(ans)