import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
W = LI()


min_v = 1000000
for t in range(1,N+1):

    a = sum(W[:t])
    b = sum(W[t:])
    min_v = min(min_v,abs(a-b)) 
print(min_v) import sys sys def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def S(): return sys.stdin.readline().rstrip() S def LS(): return list(sys.stdin.readline().rstrip().split()) LS N = I() N I() I W = LI() W LI() LI min_v = 1000000 min_v 1000000 for t in range(1,N+1):

    a = sum(W[:t])
    b = sum(W[t:])
    min_v = min(min_v,abs(a-b))  t range(1,N+1) range 1 N+1 N 1 a = sum(W[:t]) a sum(W[:t]) sum W[:t] W :t t b = sum(W[t:]) b sum(W[t:]) sum W[t:] W t: t min_v = min(min_v,abs(a-b)) min_v min(min_v,abs(a-b)) min min_v abs(a-b) abs a-b a b print(min_v) print min_v def LS(): return list(sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) LS W = LI() LI() W def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI N = I() I() N def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I min_v = 1000000 1000000 min_v b = sum(W[t:]) sum(W[t:]) b a = sum(W[:t]) sum(W[:t]) a min_v = min(min_v,abs(a-b)) min(min_v,abs(a-b)) min_v
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
W = LI()


min_v = 1000000
for t in range(1,N+1):

    a = sum(W[:t])
    b = sum(W[t:])
    min_v = min(min_v,abs(a-b)) 
print(min_v)
