#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
W=input_array()

left=0
right=sum(W)
diff=right

for i in range(n):
	left+=W[i]
	right-=W[i]
	diff_tmp=right-left
	# print(diff,diff_tmp)
	if abs(diff)<=abs(diff_tmp):
		print(abs(diff))
		break
	else:
		diff=diff_tmp def input_array():
	return list(map(int,input().split()))
   input_array return list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split n=int(input()) n int(input()) int input() input W=input_array() W input_array() input_array left=0 left 0 right=sum(W) right sum(W) sum W diff=right diff right for i in range(n):
	left+=W[i]
	right-=W[i]
	diff_tmp=right-left
	# print(diff,diff_tmp)
	if abs(diff)<=abs(diff_tmp):
		print(abs(diff))
		break
	else:
		diff=diff_tmp i range(n) range n left+=W[i] left W[i] W i right-=W[i] right W[i] W i diff_tmp=right-left diff_tmp right-left right left if abs(diff)<=abs(diff_tmp):
		print(abs(diff))
		break
	else:
		diff=diff_tmp abs(diff)<=abs(diff_tmp) abs(diff) abs diff abs(diff_tmp) abs diff_tmp print(abs(diff)) print abs(diff) abs diff break diff=diff_tmp diff diff_tmp diff=diff_tmp diff_tmp diff left+=W[i] W[i] left right-=W[i] W[i] right right=sum(W) sum(W) right diff_tmp=right-left right-left diff_tmp def input_array():
	return list(map(int,input().split()))
   def input_array():
	return list(map(int,input().split()))
   input_array n=int(input()) int(input()) n left=0 0 left W=input_array() input_array() W diff=right right diff
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
W=input_array()

left=0
right=sum(W)
diff=right

for i in range(n):
	left+=W[i]
	right-=W[i]
	diff_tmp=right-left
	# print(diff,diff_tmp)
	if abs(diff)<=abs(diff_tmp):
		print(abs(diff))
		break
	else:
		diff=diff_tmp