from itertools import accumulate
N = int(input())
W = list(map(int, input().split()))
S = list(accumulate(W))
print(min(abs(S[-1]-s-s) for s in S[:-1])) from itertools import accumulate 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 = list(accumulate(W)) S list(accumulate(W)) list accumulate(W) accumulate W print(min(abs(S[-1]-s-s) for s in S[:-1])) print min(abs(S[-1]-s-s) for s in S[:-1]) min abs(S[-1]-s-s) abs S[-1]-s-s S[-1]-s S[-1] S -1 s s N = int(input()) int(input()) N W = list(map(int, input().split())) list(map(int, input().split())) W S = list(accumulate(W)) list(accumulate(W)) S
from itertools import accumulate
N = int(input())
W = list(map(int, input().split()))
S = list(accumulate(W))
print(min(abs(S[-1]-s-s) for s in S[:-1]))