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

lst = [0]*(N-1)
S1 = [W[0]]*(N-1)
S2 = [sum(W)-W[0]]*(N-1)
lst[0] = abs(S1[0]-S2[0])

for i in range(1,N-1):
    S1[i] = S1[i-1]+W[i]
    S2[i] = S2[i-1]-W[i]
    lst[i] = abs(S1[i]-S2[i])

ans = min(lst)
print(ans) 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 lst = [0]*(N-1) lst [0]*(N-1) [0] 0 N-1 N 1 S1 = [W[0]]*(N-1) S1 [W[0]]*(N-1) [W[0]] W[0] W 0 N-1 N 1 S2 = [sum(W)-W[0]]*(N-1) S2 [sum(W)-W[0]]*(N-1) [sum(W)-W[0]] sum(W)-W[0] sum(W) sum W W[0] W 0 N-1 N 1 lst[0] = abs(S1[0]-S2[0]) lst[0] lst 0 abs(S1[0]-S2[0]) abs S1[0]-S2[0] S1[0] S1 0 S2[0] S2 0 for i in range(1,N-1):
    S1[i] = S1[i-1]+W[i]
    S2[i] = S2[i-1]-W[i]
    lst[i] = abs(S1[i]-S2[i]) i range(1,N-1) range 1 N-1 N 1 S1[i] = S1[i-1]+W[i] S1[i] S1 i S1[i-1]+W[i] S1[i-1] S1 i-1 i 1 W[i] W i S2[i] = S2[i-1]-W[i] S2[i] S2 i S2[i-1]-W[i] S2[i-1] S2 i-1 i 1 W[i] W i lst[i] = abs(S1[i]-S2[i]) lst[i] lst i abs(S1[i]-S2[i]) abs S1[i]-S2[i] S1[i] S1 i S2[i] S2 i ans = min(lst) ans min(lst) min lst print(ans) print ans N = int(input()) int(input()) N lst = [0]*(N-1) [0]*(N-1) lst W = list(map(int,input().split())) list(map(int,input().split())) W S1 = [W[0]]*(N-1) [W[0]]*(N-1) S1 S2 = [sum(W)-W[0]]*(N-1) [sum(W)-W[0]]*(N-1) S2 ans = min(lst) min(lst) ans
N = int(input())
W = list(map(int,input().split()))

lst = [0]*(N-1)
S1 = [W[0]]*(N-1)
S2 = [sum(W)-W[0]]*(N-1)
lst[0] = abs(S1[0]-S2[0])

for i in range(1,N-1):
    S1[i] = S1[i-1]+W[i]
    S2[i] = S2[i-1]-W[i]
    lst[i] = abs(S1[i]-S2[i])

ans = min(lst)
print(ans)
