N = int(eval(input()))

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

ans = 10000



for T in range(1, N):

    s1 = 0

    s2 = 0

    for i in range(len(S)):

        if i+1 <= T:

            s1 += S[i]

        if i+1 > T:

            s2 += S[i]

    if abs(s1 - s2) < ans:

        ans = abs(s1 - s2)

        

print (ans)





N = int(eval(input()))

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

ans = 10000



for T in range(1, N):

    s1 = sum(S[:T+1])

    s2 = sum(S[T+1:])



    diff = abs(s1 - s2)

    if diff < ans:

        ans = diff

        

print (ans)





N = int(eval(input()))
S = list(map(int, input().split()))
ans = 10000
for T in range(1, N):
    s1 = 0
    s2 = 0
    for i in range(len(S)):
        if i + 1 <= T:
            s1 += S[i]
        if i + 1 > T:
            s2 += S[i]
    if abs(s1 - s2) < ans:
        ans = abs(s1 - s2)
print(ans)

N = int(eval(input()))
S = list(map(int, input().split()))
ans = 10000
for T in range(1, N):
    s1 = sum(S[: T + 1])
    s2 = sum(S[T + 1 :])
    diff = abs(s1 - s2)
    if diff < ans:
        ans = diff
print(ans)

-    s1 = 0 -    s2 = 0 -    for i in range(len(S)): -        if i + 1 <= T: -            s1 += S[i] -        if i + 1 > T: -            s2 += S[i] -    if abs(s1 - s2) < ans: -        ans = abs(s1 - s2) +    s1 = sum(S[: T + 1]) +    s2 = sum(S[T + 1 :]) +    diff = abs(s1 - s2) +    if diff < ans: +        ans = diff