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

s = sum(w)
t = 0
res = 10**18
for ww in w:
    t += ww
    res = min(abs(s-t-t), res)
print(res) 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 t = 0 t 0 res = 10**18 res 10**18 10 18 for ww in w:
    t += ww
    res = min(abs(s-t-t), res) ww w t += ww t ww res = min(abs(s-t-t), res) res min(abs(s-t-t), res) min abs(s-t-t) abs s-t-t s-t s t t res print(res) print res s = sum(w) sum(w) s res = 10**18 10**18 res w = list(map(int, input().split())) list(map(int, input().split())) w res = min(abs(s-t-t), res) min(abs(s-t-t), res) res t += ww ww t t = 0 0 t n = int(input()) int(input()) n
n = int(input())
w = list(map(int, input().split()))

s = sum(w)
t = 0
res = 10**18
for ww in w:
    t += ww
    res = min(abs(s-t-t), res)
print(res)
