n,*w=map(int,open(0).read().split())
s=10**9
sum_w=sum(w)
for i in range(1,n):
	s=min(s,abs(sum_w-2*sum(w[:i])))
print(s)  n,*w=map(int,open(0).read().split()) n map(int,open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split *w w s=10**9 s 10**9 10 9 sum_w=sum(w) sum_w sum(w) sum w for i in range(1,n):
	s=min(s,abs(sum_w-2*sum(w[:i]))) i range(1,n) range 1 n s=min(s,abs(sum_w-2*sum(w[:i]))) s min(s,abs(sum_w-2*sum(w[:i]))) min s abs(sum_w-2*sum(w[:i])) abs sum_w-2*sum(w[:i]) sum_w 2*sum(w[:i]) 2 sum(w[:i]) sum w[:i] w :i i print(s) print s s=min(s,abs(sum_w-2*sum(w[:i]))) min(s,abs(sum_w-2*sum(w[:i]))) s n,*w=map(int,open(0).read().split()) map(int,open(0).read().split()) n s=10**9 10**9 s sum_w=sum(w) sum(w) sum_w
n,*w=map(int,open(0).read().split())
s=10**9
sum_w=sum(w)
for i in range(1,n):
	s=min(s,abs(sum_w-2*sum(w[:i])))
print(s) 