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

m = abs(sum(W)-W[0])
L = W[0]

for i in range(1, n-1):
    L += W[i]
    m = min(abs(sum(W)-2*L), m)
    
print(m) import copy copy 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 m = abs(sum(W)-W[0]) m abs(sum(W)-W[0]) abs sum(W)-W[0] sum(W) sum W W[0] W 0 L = W[0] L W[0] W 0 for i in range(1, n-1):
    L += W[i]
    m = min(abs(sum(W)-2*L), m)
     i range(1, n-1) range 1 n-1 n 1 L += W[i] L W[i] W i m = min(abs(sum(W)-2*L), m) m min(abs(sum(W)-2*L), m) min abs(sum(W)-2*L) abs sum(W)-2*L sum(W) sum W 2*L 2 L m print(m) print m n = int(input()) int(input()) n L = W[0] W[0] L m = abs(sum(W)-W[0]) abs(sum(W)-W[0]) m W = list(map(int, input().split())) list(map(int, input().split())) W L += W[i] W[i] L m = min(abs(sum(W)-2*L), m) min(abs(sum(W)-2*L), m) m
import copy
n = int(input())
W = list(map(int, input().split()))

m = abs(sum(W)-W[0])
L = W[0]

for i in range(1, n-1):
    L += W[i]
    m = min(abs(sum(W)-2*L), m)
    
print(m)
