def main():
  n = int(input())
  wlist = list(map(int, input().split()))
  min_diff = float('inf')
  for i in range(1, n):
    s1 = sum(wlist[:i])
    s2 = sum(wlist[i:])
    diff = abs(s1-s2)
    if min_diff > diff:
      min_diff = diff
  print(min_diff)
main() def main():
  n = int(input())
  wlist = list(map(int, input().split()))
  min_diff = float('inf')
  for i in range(1, n):
    s1 = sum(wlist[:i])
    s2 = sum(wlist[i:])
    diff = abs(s1-s2)
    if min_diff > diff:
      min_diff = diff
  print(min_diff) main n = int(input()) n int(input()) int input() input wlist = list(map(int, input().split())) wlist list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split min_diff = float('inf') min_diff float('inf') float 'inf' for i in range(1, n):
    s1 = sum(wlist[:i])
    s2 = sum(wlist[i:])
    diff = abs(s1-s2)
    if min_diff > diff:
      min_diff = diff
   i range(1, n) range 1 n s1 = sum(wlist[:i]) s1 sum(wlist[:i]) sum wlist[:i] wlist :i i s2 = sum(wlist[i:]) s2 sum(wlist[i:]) sum wlist[i:] wlist i: i diff = abs(s1-s2) diff abs(s1-s2) abs s1-s2 s1 s2 if min_diff > diff:
      min_diff = diff
   min_diff > diff min_diff diff min_diff = diff min_diff diff print(min_diff) print min_diff main() main def main():
  n = int(input())
  wlist = list(map(int, input().split()))
  min_diff = float('inf')
  for i in range(1, n):
    s1 = sum(wlist[:i])
    s2 = sum(wlist[i:])
    diff = abs(s1-s2)
    if min_diff > diff:
      min_diff = diff
  print(min_diff) def main():
  n = int(input())
  wlist = list(map(int, input().split()))
  min_diff = float('inf')
  for i in range(1, n):
    s1 = sum(wlist[:i])
    s2 = sum(wlist[i:])
    diff = abs(s1-s2)
    if min_diff > diff:
      min_diff = diff
  print(min_diff) main
def main():
  n = int(input())
  wlist = list(map(int, input().split()))
  min_diff = float('inf')
  for i in range(1, n):
    s1 = sum(wlist[:i])
    s2 = sum(wlist[i:])
    diff = abs(s1-s2)
    if min_diff > diff:
      min_diff = diff
  print(min_diff)
main()