import math, sys
inp = int(input())
var = list(map(int,input().split()))
l = []
for i in range(inp-1):
  a = math.fabs(sum(var[0:i+1]) - sum(var[i+1:inp+1]))
  if a==0:
        print(0)
        sys.exit()
  l.append(a)
l.sort()
print(int(l[0])) import math, sys math sys inp = int(input()) inp int(input()) int input() input var = list(map(int,input().split())) var list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split l = [] l [] for i in range(inp-1):
  a = math.fabs(sum(var[0:i+1]) - sum(var[i+1:inp+1]))
  if a==0:
        print(0)
        sys.exit()
  l.append(a) i range(inp-1) range inp-1 inp 1 a = math.fabs(sum(var[0:i+1]) - sum(var[i+1:inp+1])) a math.fabs(sum(var[0:i+1]) - sum(var[i+1:inp+1])) math.fabs math fabs sum(var[0:i+1]) - sum(var[i+1:inp+1]) sum(var[0:i+1]) sum var[0:i+1] var 0:i+1 0 i+1 i 1 sum(var[i+1:inp+1]) sum var[i+1:inp+1] var i+1:inp+1 i+1 i 1 inp+1 inp 1 if a==0:
        print(0)
        sys.exit()
   a==0 a 0 print(0) print 0 sys.exit() sys.exit sys exit l.append(a) l.append l append a l.sort() l.sort l sort print(int(l[0])) print int(l[0]) int l[0] l 0 a = math.fabs(sum(var[0:i+1]) - sum(var[i+1:inp+1])) math.fabs(sum(var[0:i+1]) - sum(var[i+1:inp+1])) a l = [] [] l var = list(map(int,input().split())) list(map(int,input().split())) var inp = int(input()) int(input()) inp
import math, sys
inp = int(input())
var = list(map(int,input().split()))
l = []
for i in range(inp-1):
  a = math.fabs(sum(var[0:i+1]) - sum(var[i+1:inp+1]))
  if a==0:
        print(0)
        sys.exit()
  l.append(a)
l.sort()
print(int(l[0]))