import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, li = ri(), rl()
min_ = inf
for i in range(1, n):
  min_ = min(abs(sum(li[0:i]) - sum(li[i:])), min_)
print(min_)



 import sys sys import math math import itertools itertools import collections collections import heapq heapq import re re import numpy as np numpy rr = lambda: sys.stdin.readline().rstrip() rr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip rs = lambda: sys.stdin.readline().split() rs lambda: sys.stdin.readline().split() sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split ri = lambda: int(sys.stdin.readline()) ri lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rm = lambda: map(int, sys.stdin.readline().split()) rm lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split rl = lambda: list(map(int, sys.stdin.readline().split())) rl lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split inf = float('inf') inf float('inf') float 'inf' mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 n, li = ri(), rl() n ri() ri li rl() rl min_ = inf min_ inf for i in range(1, n):
  min_ = min(abs(sum(li[0:i]) - sum(li[i:])), min_) i range(1, n) range 1 n min_ = min(abs(sum(li[0:i]) - sum(li[i:])), min_) min_ min(abs(sum(li[0:i]) - sum(li[i:])), min_) min abs(sum(li[0:i]) - sum(li[i:])) abs sum(li[0:i]) - sum(li[i:]) sum(li[0:i]) sum li[0:i] li 0:i 0 i sum(li[i:]) sum li[i:] li i: i min_ print(min_) print min_ mod = 10**9 + 7 10**9 + 7 mod rs = lambda: sys.stdin.readline().split() lambda: sys.stdin.readline().split() rs ri = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ri min_ = inf inf min_ rl = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) rl rm = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) rm li = ri(), rl() rl() li rr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() rr min_ = min(abs(sum(li[0:i]) - sum(li[i:])), min_) min(abs(sum(li[0:i]) - sum(li[i:])), min_) min_ inf = float('inf') float('inf') inf n, li = ri(), rl() ri() n
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, li = ri(), rl()
min_ = inf
for i in range(1, n):
  min_ = min(abs(sum(li[0:i]) - sum(li[i:])), min_)
print(min_)




