n = int(input())
W = list(map(int,input().split()))
W_sum = sum(W)
ans = W_sum
num = 0

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

for i in range(n):
    num += W[i]
    ans = min(ans,abs(2*num-W_sum))
print(ans)
