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