N = int(input())
W = list(map(int,input().split()))
p = sum(W)
q = 0
for i in range(N):
    q += W[i]
    if q >= p/2:
        print(min(abs(p-2*sum(W[:i])),abs(p-2*sum(W[:i+1]))))
        exit() 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 p = sum(W) p sum(W) sum W q = 0 q 0 for i in range(N):
    q += W[i]
    if q >= p/2:
        print(min(abs(p-2*sum(W[:i])),abs(p-2*sum(W[:i+1]))))
        exit() i range(N) range N q += W[i] q W[i] W i if q >= p/2:
        print(min(abs(p-2*sum(W[:i])),abs(p-2*sum(W[:i+1]))))
        exit() q >= p/2 q p/2 p 2 print(min(abs(p-2*sum(W[:i])),abs(p-2*sum(W[:i+1])))) print min(abs(p-2*sum(W[:i])),abs(p-2*sum(W[:i+1]))) min abs(p-2*sum(W[:i])) abs p-2*sum(W[:i]) p 2*sum(W[:i]) 2 sum(W[:i]) sum W[:i] W :i i abs(p-2*sum(W[:i+1])) abs p-2*sum(W[:i+1]) p 2*sum(W[:i+1]) 2 sum(W[:i+1]) sum W[:i+1] W :i+1 i+1 i 1 exit() exit W = list(map(int,input().split())) list(map(int,input().split())) W N = int(input()) int(input()) N q = 0 0 q q += W[i] W[i] q p = sum(W) sum(W) p
N = int(input())
W = list(map(int,input().split()))
p = sum(W)
q = 0
for i in range(N):
    q += W[i]
    if q >= p/2:
        print(min(abs(p-2*sum(W[:i])),abs(p-2*sum(W[:i+1]))))
        exit()