n = int(input())
w = list(map(int,input().split()))
a = 0
b = sum(w)
kai = b-a
ichizi = 0
for i in range(n):
  a +=w[i]
  b -=w[i]
  ichizi = abs(a-b)
  kai = min(kai,ichizi)
print(kai) 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 a = 0 a 0 b = sum(w) b sum(w) sum w kai = b-a kai b-a b a ichizi = 0 ichizi 0 for i in range(n):
  a +=w[i]
  b -=w[i]
  ichizi = abs(a-b)
  kai = min(kai,ichizi) i range(n) range n a +=w[i] a w[i] w i b -=w[i] b w[i] w i ichizi = abs(a-b) ichizi abs(a-b) abs a-b a b kai = min(kai,ichizi) kai min(kai,ichizi) min kai ichizi print(kai) print kai w = list(map(int,input().split())) list(map(int,input().split())) w kai = b-a b-a kai a = 0 0 a n = int(input()) int(input()) n ichizi = 0 0 ichizi b -=w[i] w[i] b a +=w[i] w[i] a ichizi = abs(a-b) abs(a-b) ichizi b = sum(w) sum(w) b kai = min(kai,ichizi) min(kai,ichizi) kai
n = int(input())
w = list(map(int,input().split()))
a = 0
b = sum(w)
kai = b-a
ichizi = 0
for i in range(n):
  a +=w[i]
  b -=w[i]
  ichizi = abs(a-b)
  kai = min(kai,ichizi)
print(kai)