N = int(input())
W = list(map(int, input().split()))
a = 0
b = sum(W)
dif = b

for i in range(N):
  a += W[i]
  b -= W[i]
  if dif > abs(b-a):
    dif = abs(b-a)
  else:
    break
    
print(dif) 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 a = 0 a 0 b = sum(W) b sum(W) sum W dif = b dif b for i in range(N):
  a += W[i]
  b -= W[i]
  if dif > abs(b-a):
    dif = abs(b-a)
  else:
    break
     i range(N) range N a += W[i] a W[i] W i b -= W[i] b W[i] W i if dif > abs(b-a):
    dif = abs(b-a)
  else:
    break
     dif > abs(b-a) dif abs(b-a) abs b-a b a dif = abs(b-a) dif abs(b-a) abs b-a b a break print(dif) print dif a = 0 0 a dif = b b dif W = list(map(int, input().split())) list(map(int, input().split())) W b -= W[i] W[i] b N = int(input()) int(input()) N dif = abs(b-a) abs(b-a) dif a += W[i] W[i] a b = sum(W) sum(W) b
N = int(input())
W = list(map(int, input().split()))
a = 0
b = sum(W)
dif = b

for i in range(N):
  a += W[i]
  b -= W[i]
  if dif > abs(b-a):
    dif = abs(b-a)
  else:
    break
    
print(dif)