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

S1 = 0
S2 = sum(W)
ans = float("inf")
for w in W:
    S1 += w
    S2 -= w
    ans = min(ans, abs(S1 - S2))
print(ans) 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 S1 = 0 S1 0 S2 = sum(W) S2 sum(W) sum W ans = float("inf") ans float("inf") float "inf" for w in W:
    S1 += w
    S2 -= w
    ans = min(ans, abs(S1 - S2)) w W S1 += w S1 w S2 -= w S2 w ans = min(ans, abs(S1 - S2)) ans min(ans, abs(S1 - S2)) min ans abs(S1 - S2) abs S1 - S2 S1 S2 print(ans) print ans S1 = 0 0 S1 W = list(map(int, input().split())) list(map(int, input().split())) W S2 = sum(W) sum(W) S2 S1 += w w S1 ans = float("inf") float("inf") ans ans = min(ans, abs(S1 - S2)) min(ans, abs(S1 - S2)) ans S2 -= w w S2 N = int(input()) int(input()) N
N = int(input())
W = list(map(int, input().split()))

S1 = 0
S2 = sum(W)
ans = float("inf")
for w in W:
    S1 += w
    S2 -= w
    ans = min(ans, abs(S1 - S2))
print(ans)