n = int(input())
w = list(map(int,input().split()))
ans = 10**9
for i in range(1,n):
    l1 = w[:i]
    l2 = w[i:]
    ans = min(ans,abs(sum(l1)-sum(l2)))
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 = 10**9 ans 10**9 10 9 for i in range(1,n):
    l1 = w[:i]
    l2 = w[i:]
    ans = min(ans,abs(sum(l1)-sum(l2))) i range(1,n) range 1 n l1 = w[:i] l1 w[:i] w :i i l2 = w[i:] l2 w[i:] w i: i ans = min(ans,abs(sum(l1)-sum(l2))) ans min(ans,abs(sum(l1)-sum(l2))) min ans abs(sum(l1)-sum(l2)) abs sum(l1)-sum(l2) sum(l1) sum l1 sum(l2) sum l2 print(ans) print ans ans = 10**9 10**9 ans w = list(map(int,input().split())) list(map(int,input().split())) w n = int(input()) int(input()) n ans = min(ans,abs(sum(l1)-sum(l2))) min(ans,abs(sum(l1)-sum(l2))) ans l2 = w[i:] w[i:] l2 l1 = w[:i] w[:i] l1
n = int(input())
w = list(map(int,input().split()))
ans = 10**9
for i in range(1,n):
    l1 = w[:i]
    l2 = w[i:]
    ans = min(ans,abs(sum(l1)-sum(l2)))
print(ans)  