N = int(input())
W = list(map(int, input().split()))

all_W = sum(W)
i = 0
s1 = 0
while i < N:
  s1 = s1 + W[i]
  s1_minus_s2 = all_W - 2 * s1
  if s1_minus_s2 <= 0:
    print(min(abs(s1_minus_s2), abs(s1_minus_s2 + 2 * W[i])))
    break
  i += 1 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 all_W = sum(W) all_W sum(W) sum W i = 0 i 0 s1 = 0 s1 0 while i < N:
  s1 = s1 + W[i]
  s1_minus_s2 = all_W - 2 * s1
  if s1_minus_s2 <= 0:
    print(min(abs(s1_minus_s2), abs(s1_minus_s2 + 2 * W[i])))
    break
  i += 1 i < N i N s1 = s1 + W[i] s1 s1 + W[i] s1 W[i] W i s1_minus_s2 = all_W - 2 * s1 s1_minus_s2 all_W - 2 * s1 all_W 2 * s1 2 s1 if s1_minus_s2 <= 0:
    print(min(abs(s1_minus_s2), abs(s1_minus_s2 + 2 * W[i])))
    break
   s1_minus_s2 <= 0 s1_minus_s2 0 print(min(abs(s1_minus_s2), abs(s1_minus_s2 + 2 * W[i]))) print min(abs(s1_minus_s2), abs(s1_minus_s2 + 2 * W[i])) min abs(s1_minus_s2) abs s1_minus_s2 abs(s1_minus_s2 + 2 * W[i]) abs s1_minus_s2 + 2 * W[i] s1_minus_s2 2 * W[i] 2 W[i] W i break i += 1 i 1 W = list(map(int, input().split())) list(map(int, input().split())) W s1 = s1 + W[i] s1 + W[i] s1 i += 1 1 i s1 = 0 0 s1 s1_minus_s2 = all_W - 2 * s1 all_W - 2 * s1 s1_minus_s2 N = int(input()) int(input()) N all_W = sum(W) sum(W) all_W i = 0 0 i
N = int(input())
W = list(map(int, input().split()))

all_W = sum(W)
i = 0
s1 = 0
while i < N:
  s1 = s1 + W[i]
  s1_minus_s2 = all_W - 2 * s1
  if s1_minus_s2 <= 0:
    print(min(abs(s1_minus_s2), abs(s1_minus_s2 + 2 * W[i])))
    break
  i += 1