n = int(input())
w = list(map(int,input().split()))
s = sum(w)

c = 0
prev_d = float('inf')
for x in w:
    c += x
    dis = abs((s - c) - c)
    if c >= s / 2:
        print(min(dis,prev_d))
        exit()
    prev_d = dis
 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 s = sum(w) s sum(w) sum w c = 0 c 0 prev_d = float('inf') prev_d float('inf') float 'inf' for x in w:
    c += x
    dis = abs((s - c) - c)
    if c >= s / 2:
        print(min(dis,prev_d))
        exit()
    prev_d = dis x w c += x c x dis = abs((s - c) - c) dis abs((s - c) - c) abs (s - c) - c s - c s c c if c >= s / 2:
        print(min(dis,prev_d))
        exit()
     c >= s / 2 c s / 2 s 2 print(min(dis,prev_d)) print min(dis,prev_d) min dis prev_d exit() exit prev_d = dis prev_d dis s = sum(w) sum(w) s prev_d = float('inf') float('inf') prev_d n = int(input()) int(input()) n dis = abs((s - c) - c) abs((s - c) - c) dis c += x x c c = 0 0 c prev_d = dis dis prev_d w = list(map(int,input().split())) list(map(int,input().split())) w
n = int(input())
w = list(map(int,input().split()))
s = sum(w)

c = 0
prev_d = float('inf')
for x in w:
    c += x
    dis = abs((s - c) - c)
    if c >= s / 2:
        print(min(dis,prev_d))
        exit()
    prev_d = dis

