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

avg = sum(W) / 2
total = 0

for i in range(N):
    total += W[i]
    if total >= avg:
        a = total
        b = total - W[i]
        break

print(min(2 * a - sum(W), sum(W) - 2 * b)) 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 avg = sum(W) / 2 avg sum(W) / 2 sum(W) sum W 2 total = 0 total 0 for i in range(N):
    total += W[i]
    if total >= avg:
        a = total
        b = total - W[i]
        break i range(N) range N total += W[i] total W[i] W i if total >= avg:
        a = total
        b = total - W[i]
        break total >= avg total avg a = total a total b = total - W[i] b total - W[i] total W[i] W i break print(min(2 * a - sum(W), sum(W) - 2 * b)) print min(2 * a - sum(W), sum(W) - 2 * b) min 2 * a - sum(W) 2 * a 2 a sum(W) sum W sum(W) - 2 * b sum(W) sum W 2 * b 2 b avg = sum(W) / 2 sum(W) / 2 avg total += W[i] W[i] total W = list(map(int, input().split())) list(map(int, input().split())) W b = total - W[i] total - W[i] b a = total total a N = int(input()) int(input()) N total = 0 0 total
N = int(input())
W = list(map(int, input().split()))

avg = sum(W) / 2
total = 0

for i in range(N):
    total += W[i]
    if total >= avg:
        a = total
        b = total - W[i]
        break

print(min(2 * a - sum(W), sum(W) - 2 * b))
