import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
S = l()
sa = 1000000000

for i in range(1,N):
    sa = min(sa,abs(sum(S[:i])-sum(S[i:])))

print(sa) import sys sys import math math import itertools itertools import bisect bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() s def i(): return int(input()) i def S(): return input().split() S def I(): return map(int,input().split()) I def X(): return list(input()) X def L(): return list(input().split()) L def l(): return list(map(int,input().split())) l def lcm(a,b): return a*b//math.gcd(a,b) lcm a a b b sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 N = i() N i() i S = l() S l() l sa = 1000000000 sa 1000000000 for i in range(1,N):
    sa = min(sa,abs(sum(S[:i])-sum(S[i:]))) i range(1,N) range 1 N sa = min(sa,abs(sum(S[:i])-sum(S[i:]))) sa min(sa,abs(sum(S[:i])-sum(S[i:]))) min sa abs(sum(S[:i])-sum(S[i:])) abs sum(S[:i])-sum(S[i:]) sum(S[:i]) sum S[:i] S :i i sum(S[i:]) sum S[i:] S i: i print(sa) print sa sa = min(sa,abs(sum(S[:i])-sum(S[i:]))) min(sa,abs(sum(S[:i])-sum(S[i:]))) sa def lcm(a,b): return a*b//math.gcd(a,b) def lcm(a,b): return a*b//math.gcd(a,b) lcm mod = 10**9+7 10**9+7 mod def I(): return map(int,input().split()) def I(): return map(int,input().split()) I N = i() i() N sa = 1000000000 1000000000 sa def X(): return list(input()) def X(): return list(input()) X def i(): return int(input()) def i(): return int(input()) i def S(): return input().split() def S(): return input().split() S def l(): return list(map(int,input().split())) def l(): return list(map(int,input().split())) l S = l() l() S def s(): return input() def s(): return input() s def L(): return list(input().split()) def L(): return list(input().split()) L
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
S = l()
sa = 1000000000

for i in range(1,N):
    sa = min(sa,abs(sum(S[:i])-sum(S[i:])))

print(sa)
