n = int(eval(input()))

a = [int(i) for i in input().split()]



ret = 1000

for i in range(1, n):

    s = abs(sum(a[:i]) - sum(a[i:]))

    if s < ret:

        ret = s

print(ret)
from sys import stdin

n = int(eval(input()))

a = [int(i) for i in stdin.readline().rstrip().split()]



ret = 1000

for i in range(1, n):

    s = abs(sum(a[:i]) - sum(a[i:]))

    if s < ret:

        ret = s

print(ret)

n = int(eval(input()))
a = [int(i) for i in input().split()]
ret = 1000
for i in range(1, n):
    s = abs(sum(a[:i]) - sum(a[i:]))
    if s < ret:
        ret = s
print(ret)

from sys import stdin

n = int(eval(input()))
a = [int(i) for i in stdin.readline().rstrip().split()]
ret = 1000
for i in range(1, n):
    s = abs(sum(a[:i]) - sum(a[i:]))
    if s < ret:
        ret = s
print(ret)

+from sys import stdin + -a = [int(i) for i in input().split()] +a = [int(i) for i in stdin.readline().rstrip().split()]