import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
W = LI()
ans = math.inf
for i in range(n):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans) import bisect,collections,copy,heapq,itertools,math,string bisect collections copy heapq itertools math string import sys sys def S(): return sys.stdin.readline().rstrip() S def M(): return map(int,sys.stdin.readline().rstrip().split()) M def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def LS(): return list(sys.stdin.readline().rstrip().split()) LS n = I() n I() I W = LI() W LI() LI ans = math.inf ans math.inf math inf for i in range(n):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:]))) i range(n) range n ans = min(ans, abs(sum(W[:i]) - sum(W[i:]))) ans min(ans, abs(sum(W[:i]) - sum(W[i:]))) min ans abs(sum(W[:i]) - sum(W[i:])) abs sum(W[:i]) - sum(W[i:]) sum(W[:i]) sum W[:i] W :i i sum(W[i:]) sum W[i:] W i: i print(ans) print ans 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 def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I W = LI() LI() W n = I() I() n ans = math.inf math.inf ans def M(): return map(int,sys.stdin.readline().rstrip().split()) def M(): return map(int,sys.stdin.readline().rstrip().split()) M ans = min(ans, abs(sum(W[:i]) - sum(W[i:]))) min(ans, abs(sum(W[:i]) - sum(W[i:]))) ans def LS(): return list(sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) LS
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
W = LI()
ans = math.inf
for i in range(n):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans)