n = int(input())
w = list(map(int, input().split()))
a = []
x = 0
for i in range(n):
    x += w[i]
    a.append(x)

b = []
for j in range(n):
    b.append(abs(2 * a[j] - a[n - 1]))
print(min(b)) 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 a = [] a [] x = 0 x 0 for i in range(n):
    x += w[i]
    a.append(x) i range(n) range n x += w[i] x w[i] w i a.append(x) a.append a append x b = [] b [] for j in range(n):
    b.append(abs(2 * a[j] - a[n - 1])) j range(n) range n b.append(abs(2 * a[j] - a[n - 1])) b.append b append abs(2 * a[j] - a[n - 1]) abs 2 * a[j] - a[n - 1] 2 * a[j] 2 a[j] a j a[n - 1] a n - 1 n 1 print(min(b)) print min(b) min b a = [] [] a b = [] [] b n = int(input()) int(input()) n w = list(map(int, input().split())) list(map(int, input().split())) w x += w[i] w[i] x x = 0 0 x
n = int(input())
w = list(map(int, input().split()))
a = []
x = 0
for i in range(n):
    x += w[i]
    a.append(x)

b = []
for j in range(n):
    b.append(abs(2 * a[j] - a[n - 1]))
print(min(b))