N = int(input())
W = list(map(int,input().split()))
W.insert(N,0)
left,right = 0,0
S = 1000
for i in range(0,N):
	left += W[i]
	right = sum(W) - left
	S =min(S,abs(left - right))
print(S) 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.insert(N,0) W.insert W insert N 0 left,right = 0,0 left 0 right 0 S = 1000 S 1000 for i in range(0,N):
	left += W[i]
	right = sum(W) - left
	S =min(S,abs(left - right)) i range(0,N) range 0 N left += W[i] left W[i] W i right = sum(W) - left right sum(W) - left sum(W) sum W left S =min(S,abs(left - right)) S min(S,abs(left - right)) min S abs(left - right) abs left - right left right print(S) print S N = int(input()) int(input()) N right = sum(W) - left sum(W) - left right W = list(map(int,input().split())) list(map(int,input().split())) W right = 0,0 0 right S = 1000 1000 S left,right = 0,0 0 left left += W[i] W[i] left S =min(S,abs(left - right)) min(S,abs(left - right)) S
N = int(input())
W = list(map(int,input().split()))
W.insert(N,0)
left,right = 0,0
S = 1000
for i in range(0,N):
	left += W[i]
	right = sum(W) - left
	S =min(S,abs(left - right))
print(S)