import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
W = rl()

ans = float('inf')
for i in range(N-1):
	d = abs(sum(W[:i+1])-sum(W[i+1:]))
	ans = min(ans, d)
print(ans) import sys, math sys math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline rs = lambda: input().strip() rs lambda: input().strip() input().strip() ().strip () input strip ri = lambda: int(input()) ri lambda: int(input()) int(input()) int input() input rl = lambda: list(map(int, input().split())) rl lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split mod = 1000000007 mod 1000000007 sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 N = ri() N ri() ri W = rl() W rl() rl ans = float('inf') ans float('inf') float 'inf' for i in range(N-1):
	d = abs(sum(W[:i+1])-sum(W[i+1:]))
	ans = min(ans, d) i range(N-1) range N-1 N 1 d = abs(sum(W[:i+1])-sum(W[i+1:])) d abs(sum(W[:i+1])-sum(W[i+1:])) abs sum(W[:i+1])-sum(W[i+1:]) sum(W[:i+1]) sum W[:i+1] W :i+1 i+1 i 1 sum(W[i+1:]) sum W[i+1:] W i+1: i+1 i 1 ans = min(ans, d) ans min(ans, d) min ans d print(ans) print ans d = abs(sum(W[:i+1])-sum(W[i+1:])) abs(sum(W[:i+1])-sum(W[i+1:])) d ri = lambda: int(input()) lambda: int(input()) ri rl = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) rl mod = 1000000007 1000000007 mod rs = lambda: input().strip() lambda: input().strip() rs W = rl() rl() W ans = float('inf') float('inf') ans input = sys.stdin.readline sys.stdin.readline input N = ri() ri() N ans = min(ans, d) min(ans, d) ans
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
W = rl()

ans = float('inf')
for i in range(N-1):
	d = abs(sum(W[:i+1])-sum(W[i+1:]))
	ans = min(ans, d)
print(ans)
