n = int(input())
W = list(map(int, input().split()))
sumW = sum(W)

ans = 10 ** 9
p = 0
for w in W:
  p += w
  ans = min(ans, abs(sumW - 2 * p))

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 sumW = sum(W) sumW sum(W) sum W ans = 10 ** 9 ans 10 ** 9 10 9 p = 0 p 0 for w in W:
  p += w
  ans = min(ans, abs(sumW - 2 * p)) w W p += w p w ans = min(ans, abs(sumW - 2 * p)) ans min(ans, abs(sumW - 2 * p)) min ans abs(sumW - 2 * p) abs sumW - 2 * p sumW 2 * p 2 p print(ans) print ans W = list(map(int, input().split())) list(map(int, input().split())) W n = int(input()) int(input()) n sumW = sum(W) sum(W) sumW p = 0 0 p p += w w p ans = min(ans, abs(sumW - 2 * p)) min(ans, abs(sumW - 2 * p)) ans ans = 10 ** 9 10 ** 9 ans
n = int(input())
W = list(map(int, input().split()))
sumW = sum(W)

ans = 10 ** 9
p = 0
for w in W:
  p += w
  ans = min(ans, abs(sumW - 2 * p))

print(ans)