N = int(input())
W = list(map(int,input().split()))
# abs_list = list()
# for i in range(len(W)):
# 	abs_list.append(abs(sum(W[:i+1])-sum(W[i+1:])))
# print(min(abs_list))

W_sum = list()
W_sum.append(0)
for i in range(N):
	W_sum.append(W_sum[i] + W[i])

ans = 100000007
for i in range(len(W_sum)):
	ans = min(ans, abs((W_sum[N] - W_sum[i]) - W_sum[i]))

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

W_sum = list()
W_sum.append(0)
for i in range(N):
	W_sum.append(W_sum[i] + W[i])

ans = 100000007
for i in range(len(W_sum)):
	ans = min(ans, abs((W_sum[N] - W_sum[i]) - W_sum[i]))

print(ans)
