n = int(input())
w = list(map(int,input().split()))

total = sum(w)
s2 = total
minimum = total
for i in range(1,n):
    s2 -= w[i-1]
    minimum = min(minimum,abs(total-s2*2))
print(minimum) 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 total = sum(w) total sum(w) sum w s2 = total s2 total minimum = total minimum total for i in range(1,n):
    s2 -= w[i-1]
    minimum = min(minimum,abs(total-s2*2)) i range(1,n) range 1 n s2 -= w[i-1] s2 w[i-1] w i-1 i 1 minimum = min(minimum,abs(total-s2*2)) minimum min(minimum,abs(total-s2*2)) min minimum abs(total-s2*2) abs total-s2*2 total s2*2 s2 2 print(minimum) print minimum minimum = min(minimum,abs(total-s2*2)) min(minimum,abs(total-s2*2)) minimum total = sum(w) sum(w) total w = list(map(int,input().split())) list(map(int,input().split())) w s2 -= w[i-1] w[i-1] s2 n = int(input()) int(input()) n s2 = total total s2 minimum = total total minimum
n = int(input())
w = list(map(int,input().split()))

total = sum(w)
s2 = total
minimum = total
for i in range(1,n):
    s2 -= w[i-1]
    minimum = min(minimum,abs(total-s2*2))
print(minimum)
