import numpy as np

n = eval(input())

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

w = np.array(w)

print((np.min(np.abs(2 * np.cumsum(w) -np.sum(w)))))
n = int(eval(input()))

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

ans = sum(w)

for i in range(1,n):

    ans = min(ans,abs(sum(w[:i + 1]) - sum(w[i +1:])))

print(ans)
import numpy as np

n = eval(input())
w = list(map(int, input().split()))
w = np.array(w)
print((np.min(np.abs(2 * np.cumsum(w) - np.sum(w)))))

n = int(eval(input()))
w = list(map(int, input().split()))
ans = sum(w)
for i in range(1, n):
    ans = min(ans, abs(sum(w[: i + 1]) - sum(w[i + 1 :])))
print(ans)

-import numpy as np - -n = eval(input()) +n = int(eval(input())) -w = np.array(w) -print((np.min(np.abs(2 * np.cumsum(w) - np.sum(w))))) +ans = sum(w) +for i in range(1, n): +    ans = min(ans, abs(sum(w[: i + 1]) - sum(w[i + 1 :]))) +print(ans)