n = int(input())
weight = list(map(int, input().split()))

s = [0] * (n+1)
total = 0
for i in range(0, n):
    s[i+1] = s[i] + weight[i]
    total += weight[i]

minimum_weight = total

for i in range(1, n):
    minimum_weight = min(minimum_weight, abs(s[i] - (total - s[i])))

print(minimum_weight) n = int(input()) n int(input()) int input() input weight = list(map(int, input().split())) weight list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s = [0] * (n+1) s [0] * (n+1) [0] 0 n+1 n 1 total = 0 total 0 for i in range(0, n):
    s[i+1] = s[i] + weight[i]
    total += weight[i] i range(0, n) range 0 n s[i+1] = s[i] + weight[i] s[i+1] s i+1 i 1 s[i] + weight[i] s[i] s i weight[i] weight i total += weight[i] total weight[i] weight i minimum_weight = total minimum_weight total for i in range(1, n):
    minimum_weight = min(minimum_weight, abs(s[i] - (total - s[i]))) i range(1, n) range 1 n minimum_weight = min(minimum_weight, abs(s[i] - (total - s[i]))) minimum_weight min(minimum_weight, abs(s[i] - (total - s[i]))) min minimum_weight abs(s[i] - (total - s[i])) abs s[i] - (total - s[i]) s[i] s i total - s[i] total s[i] s i print(minimum_weight) print minimum_weight n = int(input()) int(input()) n minimum_weight = total total minimum_weight weight = list(map(int, input().split())) list(map(int, input().split())) weight s = [0] * (n+1) [0] * (n+1) s total += weight[i] weight[i] total minimum_weight = min(minimum_weight, abs(s[i] - (total - s[i]))) min(minimum_weight, abs(s[i] - (total - s[i]))) minimum_weight total = 0 0 total
n = int(input())
weight = list(map(int, input().split()))

s = [0] * (n+1)
total = 0
for i in range(0, n):
    s[i+1] = s[i] + weight[i]
    total += weight[i]

minimum_weight = total

for i in range(1, n):
    minimum_weight = min(minimum_weight, abs(s[i] - (total - s[i])))

print(minimum_weight)