# 129 B

n = int(input())
l = list(map(int, input().split()))
diff = (100 ** 100)

for t in range(len(l)):
    s1 = 0
    s2 = 0

    for i in range(len(l)):
        if i <= t:
            s1 += l[i]
        else:
            s2 += l[i]
    x = abs(s2 - s1)     
    if x <= diff:
        diff = x 
         
print(diff)
     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 diff = (100 ** 100) diff 100 ** 100 100 100 for t in range(len(l)):
    s1 = 0
    s2 = 0

    for i in range(len(l)):
        if i <= t:
            s1 += l[i]
        else:
            s2 += l[i]
    x = abs(s2 - s1)     
    if x <= diff:
        diff = x 
          t range(len(l)) range len(l) len l s1 = 0 s1 0 s2 = 0 s2 0 for i in range(len(l)):
        if i <= t:
            s1 += l[i]
        else:
            s2 += l[i]
     i range(len(l)) range len(l) len l if i <= t:
            s1 += l[i]
        else:
            s2 += l[i]
     i <= t i t s1 += l[i] s1 l[i] l i s2 += l[i] s2 l[i] l i x = abs(s2 - s1) x abs(s2 - s1) abs s2 - s1 s2 s1 if x <= diff:
        diff = x 
          x <= diff x diff diff = x diff x print(diff) print diff diff = x x diff x = abs(s2 - s1) abs(s2 - s1) x n = int(input()) int(input()) n s2 = 0 0 s2 l = list(map(int, input().split())) list(map(int, input().split())) l s2 += l[i] l[i] s2 s1 += l[i] l[i] s1 diff = (100 ** 100) 100 ** 100 diff s1 = 0 0 s1
# 129 B

n = int(input())
l = list(map(int, input().split()))
diff = (100 ** 100)

for t in range(len(l)):
    s1 = 0
    s2 = 0

    for i in range(len(l)):
        if i <= t:
            s1 += l[i]
        else:
            s2 += l[i]
    x = abs(s2 - s1)     
    if x <= diff:
        diff = x 
         
print(diff)
    
