import sys, itertools

N = int(input())
W = list(map(int, sys.stdin.readline().rsplit()))

S = list(itertools.accumulate(W))

res = 10 ** 9
for i in range(N):
    res = min(res, abs(S[i] - (S[-1] - S[i])))

print(res) import sys, itertools sys itertools N = int(input()) N int(input()) int input() input W = list(map(int, sys.stdin.readline().rsplit())) W list(map(int, sys.stdin.readline().rsplit())) list map(int, sys.stdin.readline().rsplit()) map int sys.stdin.readline().rsplit() sys.stdin.readline().rsplit sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rsplit S = list(itertools.accumulate(W)) S list(itertools.accumulate(W)) list itertools.accumulate(W) itertools.accumulate itertools accumulate W res = 10 ** 9 res 10 ** 9 10 9 for i in range(N):
    res = min(res, abs(S[i] - (S[-1] - S[i]))) i range(N) range N res = min(res, abs(S[i] - (S[-1] - S[i]))) res min(res, abs(S[i] - (S[-1] - S[i]))) min res abs(S[i] - (S[-1] - S[i])) abs S[i] - (S[-1] - S[i]) S[i] S i S[-1] - S[i] S[-1] S -1 S[i] S i print(res) print res res = min(res, abs(S[i] - (S[-1] - S[i]))) min(res, abs(S[i] - (S[-1] - S[i]))) res N = int(input()) int(input()) N res = 10 ** 9 10 ** 9 res S = list(itertools.accumulate(W)) list(itertools.accumulate(W)) S W = list(map(int, sys.stdin.readline().rsplit())) list(map(int, sys.stdin.readline().rsplit())) W
import sys, itertools

N = int(input())
W = list(map(int, sys.stdin.readline().rsplit()))

S = list(itertools.accumulate(W))

res = 10 ** 9
for i in range(N):
    res = min(res, abs(S[i] - (S[-1] - S[i])))

print(res)
