N = int(input())
l = list(map(int, input().split()))

ans = 999999

for i in range(N):
    f = l[:i]
    s = l[i:]
    diff = abs(sum(f)-sum(s))
    if diff <= ans:
        ans = diff
    
print(ans) N = int(input()) N int(input()) int input() input l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 999999 ans 999999 for i in range(N):
    f = l[:i]
    s = l[i:]
    diff = abs(sum(f)-sum(s))
    if diff <= ans:
        ans = diff
     i range(N) range N f = l[:i] f l[:i] l :i i s = l[i:] s l[i:] l i: i diff = abs(sum(f)-sum(s)) diff abs(sum(f)-sum(s)) abs sum(f)-sum(s) sum(f) sum f sum(s) sum s if diff <= ans:
        ans = diff
     diff <= ans diff ans ans = diff ans diff print(ans) print ans s = l[i:] l[i:] s l = list(map(int, input().split())) list(map(int, input().split())) l diff = abs(sum(f)-sum(s)) abs(sum(f)-sum(s)) diff N = int(input()) int(input()) N ans = 999999 999999 ans ans = diff diff ans f = l[:i] l[:i] f
N = int(input())
l = list(map(int, input().split()))

ans = 999999

for i in range(N):
    f = l[:i]
    s = l[i:]
    diff = abs(sum(f)-sum(s))
    if diff <= ans:
        ans = diff
    
print(ans)