import numpy

import math

n = int(eval(input()))

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



sum_w = sum(w)

sum_w = sum_w / 2



res = numpy.cumsum(w)



diff = [2.0 * math.fabs(res[i] - sum_w) for i in range(n)]

print((int(min(diff))))
n = int(eval(input()))

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

res = 10 ** 5

for i in range(0, n-1):

  a = abs(sum(w[:i+1]) - sum(w[i+1:]))

  if a < res:

    res = a

print(res)
import numpy
import math

n = int(eval(input()))
w = list(map(int, input().split()))
sum_w = sum(w)
sum_w = sum_w / 2
res = numpy.cumsum(w)
diff = [2.0 * math.fabs(res[i] - sum_w) for i in range(n)]
print((int(min(diff))))

n = int(eval(input()))
w = list(map(int, input().split()))
res = 10**5
for i in range(0, n - 1):
    a = abs(sum(w[: i + 1]) - sum(w[i + 1 :]))
    if a < res:
        res = a
print(res)

-import numpy -import math - -sum_w = sum(w) -sum_w = sum_w / 2 -res = numpy.cumsum(w) -diff = [2.0 * math.fabs(res[i] - sum_w) for i in range(n)] -print((int(min(diff)))) +res = 10**5 +for i in range(0, n - 1): +    a = abs(sum(w[: i + 1]) - sum(w[i + 1 :])) +    if a < res: +        res = a +print(res)