import itertools

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

all = sum(W)
W_acc = list(itertools.accumulate(W))

dif = [(all-2*W_acc[i]) for i in range(n-1)]
ans = abs(min(dif, key = abs))
print(ans) import itertools itertools 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 all = sum(W) all sum(W) sum W W_acc = list(itertools.accumulate(W)) W_acc list(itertools.accumulate(W)) list itertools.accumulate(W) itertools.accumulate itertools accumulate W (all-2*W_acc[i]) for i in range(n-1) for i in range(n-1) i range(n-1) range n-1 n 1 for i in range(n-1) all-2*W_acc[i] all 2*W_acc[i] 2 W_acc[i] W_acc i dif = [(all-2*W_acc[i]) for i in range(n-1)] dif [(all-2*W_acc[i]) for i in range(n-1)] ans = abs(min(dif, key = abs)) ans abs(min(dif, key = abs)) abs min(dif, key = abs) min dif key = abs key abs print(ans) print ans W_acc = list(itertools.accumulate(W)) list(itertools.accumulate(W)) W_acc n = int(input()) int(input()) n dif = [(all-2*W_acc[i]) for i in range(n-1)] [(all-2*W_acc[i]) for i in range(n-1)] dif all = sum(W) sum(W) all ans = abs(min(dif, key = abs)) abs(min(dif, key = abs)) ans W = list(map(int, input().split())) list(map(int, input().split())) W
import itertools

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

all = sum(W)
W_acc = list(itertools.accumulate(W))

dif = [(all-2*W_acc[i]) for i in range(n-1)]
ans = abs(min(dif, key = abs))
print(ans)