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

ans = sum(W)

L, R = sum(W), 0
for w in W:
    L -= w
    R += w
    ans = min(ans, abs(R-L))

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

ans = sum(W)

L, R = sum(W), 0
for w in W:
    L -= w
    R += w
    ans = min(ans, abs(R-L))

print(ans)