N = int(input())
W = list(map(int, input().split()))
S1 = 0
S2 = sum(W)
ans = S2
for i in range(N - 1):
	S1 += W[i]
	S2 -= W[i]
	ans = min(ans, abs(S2 - S1))
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 S1 = 0 S1 0 S2 = sum(W) S2 sum(W) sum W ans = S2 ans S2 for i in range(N - 1):
	S1 += W[i]
	S2 -= W[i]
	ans = min(ans, abs(S2 - S1)) i range(N - 1) range N - 1 N 1 S1 += W[i] S1 W[i] W i S2 -= W[i] S2 W[i] W i ans = min(ans, abs(S2 - S1)) ans min(ans, abs(S2 - S1)) min ans abs(S2 - S1) abs S2 - S1 S2 S1 print(ans) print ans S1 += W[i] W[i] S1 S1 = 0 0 S1 S2 = sum(W) sum(W) S2 S2 -= W[i] W[i] S2 ans = min(ans, abs(S2 - S1)) min(ans, abs(S2 - S1)) ans W = list(map(int, input().split())) list(map(int, input().split())) W ans = S2 S2 ans N = int(input()) int(input()) N
N = int(input())
W = list(map(int, input().split()))
S1 = 0
S2 = sum(W)
ans = S2
for i in range(N - 1):
	S1 += W[i]
	S2 -= W[i]
	ans = min(ans, abs(S2 - S1))
print(ans)	
