n = int(input())
w = list(map(int, input().split()))
p = [0 for i in range(n)]
p[0] = w[0]
for i in range(1, n):
    p[i] = p[i-1] + w[i]
diff = float('inf')
for j in range(n):
    cd = abs(p[n-1] - (2*p[j]))
    diff = min(diff, cd)
print(diff) 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 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 p = [0 for i in range(n)] p [0 for i in range(n)] p[0] = w[0] p[0] p 0 w[0] w 0 for i in range(1, n):
    p[i] = p[i-1] + w[i] i range(1, n) range 1 n p[i] = p[i-1] + w[i] p[i] p i p[i-1] + w[i] p[i-1] p i-1 i 1 w[i] w i diff = float('inf') diff float('inf') float 'inf' for j in range(n):
    cd = abs(p[n-1] - (2*p[j]))
    diff = min(diff, cd) j range(n) range n cd = abs(p[n-1] - (2*p[j])) cd abs(p[n-1] - (2*p[j])) abs p[n-1] - (2*p[j]) p[n-1] p n-1 n 1 2*p[j] 2 p[j] p j diff = min(diff, cd) diff min(diff, cd) min diff cd print(diff) print diff n = int(input()) int(input()) n cd = abs(p[n-1] - (2*p[j])) abs(p[n-1] - (2*p[j])) cd w = list(map(int, input().split())) list(map(int, input().split())) w diff = min(diff, cd) min(diff, cd) diff diff = float('inf') float('inf') diff p = [0 for i in range(n)] [0 for i in range(n)] p
n = int(input())
w = list(map(int, input().split()))
p = [0 for i in range(n)]
p[0] = w[0]
for i in range(1, n):
    p[i] = p[i-1] + w[i]
diff = float('inf')
for j in range(n):
    cd = abs(p[n-1] - (2*p[j]))
    diff = min(diff, cd)
print(diff)