# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
3
1 2 3
'''

def solve(l):
	n = len(l)
	minn = float('inf')
	for t in range(1,n):
		a = sum(l[:t])
		b = sum(l[t:])
		minn = min(minn,abs(a-b))
	return minn
	

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)
 from math import * from copy import * from heapq import * from string import * from random import * from bisect import * from sys import stdin from sys import maxsize from operator import * from itertools import * from decimal import Decimal from collections import Counter from collections import defaultdict '''
3
1 2 3
''' def solve(l):
	n = len(l)
	minn = float('inf')
	for t in range(1,n):
		a = sum(l[:t])
		b = sum(l[t:])
		minn = min(minn,abs(a-b))
	return minn
	 solve n = len(l) n len(l) len l minn = float('inf') minn float('inf') float 'inf' for t in range(1,n):
		a = sum(l[:t])
		b = sum(l[t:])
		minn = min(minn,abs(a-b))
	 t range(1,n) range 1 n a = sum(l[:t]) a sum(l[:t]) sum l[:t] l :t t b = sum(l[t:]) b sum(l[t:]) sum l[t:] l t: t minn = min(minn,abs(a-b)) minn min(minn,abs(a-b)) min minn abs(a-b) abs a-b a b return minn minn l l N = int(stdin.readline()) N int(stdin.readline()) int stdin.readline() stdin.readline stdin readline l = list(map(int, stdin.readline().rstrip().split())) l list(map(int, stdin.readline().rstrip().split())) list map(int, stdin.readline().rstrip().split()) map int stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split ans = solve(l) ans solve(l) solve l print(ans) print ans N = int(stdin.readline()) int(stdin.readline()) N def solve(l):
	n = len(l)
	minn = float('inf')
	for t in range(1,n):
		a = sum(l[:t])
		b = sum(l[t:])
		minn = min(minn,abs(a-b))
	return minn
	 def solve(l):
	n = len(l)
	minn = float('inf')
	for t in range(1,n):
		a = sum(l[:t])
		b = sum(l[t:])
		minn = min(minn,abs(a-b))
	return minn
	 solve l = list(map(int, stdin.readline().rstrip().split())) list(map(int, stdin.readline().rstrip().split())) l ans = solve(l) solve(l) ans
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
3
1 2 3
'''

def solve(l):
	n = len(l)
	minn = float('inf')
	for t in range(1,n):
		a = sum(l[:t])
		b = sum(l[t:])
		minn = min(minn,abs(a-b))
	return minn
	

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)

