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