n = int(input())
w = [int(e) for e in input().split(" ")]
w_sum = sum(w)
s_diff = []
s1 = 0
s2 = w_sum
for i in range(n+1):
    s_diff.append(abs(s2 - s1))
    if (i == n):
        break
    s1 += w[i]
    s2 -= w[i]

print(min(s_diff)) n = int(input()) n int(input()) int input() input int(e) for e in input().split(" ") for e in input().split(" ") e input().split(" ") ().split () input split " " for e in input().split(" ") int(e) int e w = [int(e) for e in input().split(" ")] w [int(e) for e in input().split(" ")] w_sum = sum(w) w_sum sum(w) sum w s_diff = [] s_diff [] s1 = 0 s1 0 s2 = w_sum s2 w_sum for i in range(n+1):
    s_diff.append(abs(s2 - s1))
    if (i == n):
        break
    s1 += w[i]
    s2 -= w[i] i range(n+1) range n+1 n 1 s_diff.append(abs(s2 - s1)) s_diff.append s_diff append abs(s2 - s1) abs s2 - s1 s2 s1 if (i == n):
        break
     i == n i n break s1 += w[i] s1 w[i] w i s2 -= w[i] s2 w[i] w i print(min(s_diff)) print min(s_diff) min s_diff s1 = 0 0 s1 w = [int(e) for e in input().split(" ")] [int(e) for e in input().split(" ")] w s_diff = [] [] s_diff s2 -= w[i] w[i] s2 n = int(input()) int(input()) n w_sum = sum(w) sum(w) w_sum s1 += w[i] w[i] s1 s2 = w_sum w_sum s2
n = int(input())
w = [int(e) for e in input().split(" ")]
w_sum = sum(w)
s_diff = []
s1 = 0
s2 = w_sum
for i in range(n+1):
    s_diff.append(abs(s2 - s1))
    if (i == n):
        break
    s1 += w[i]
    s2 -= w[i]

print(min(s_diff))
