import math
def main():
  n=int(input())
  w = list(map(int,input().split()))
  ans=abs(sum(w[:1])-sum(w[1:]))
  for t in range(2,n+1):
    if ans>abs(sum(w[:t])-sum(w[t:])):
      ans=abs(sum(w[:t])-sum(w[t:]))
  print(ans)

main() import math math def main():
  n=int(input())
  w = list(map(int,input().split()))
  ans=abs(sum(w[:1])-sum(w[1:]))
  for t in range(2,n+1):
    if ans>abs(sum(w[:t])-sum(w[t:])):
      ans=abs(sum(w[:t])-sum(w[t:]))
  print(ans) main n=int(input()) n int(input()) int input() input w = list(map(int,input().split())) w list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans=abs(sum(w[:1])-sum(w[1:])) ans abs(sum(w[:1])-sum(w[1:])) abs sum(w[:1])-sum(w[1:]) sum(w[:1]) sum w[:1] w :1 1 sum(w[1:]) sum w[1:] w 1: 1 for t in range(2,n+1):
    if ans>abs(sum(w[:t])-sum(w[t:])):
      ans=abs(sum(w[:t])-sum(w[t:]))
   t range(2,n+1) range 2 n+1 n 1 if ans>abs(sum(w[:t])-sum(w[t:])):
      ans=abs(sum(w[:t])-sum(w[t:]))
   ans>abs(sum(w[:t])-sum(w[t:])) ans abs(sum(w[:t])-sum(w[t:])) abs sum(w[:t])-sum(w[t:]) sum(w[:t]) sum w[:t] w :t t sum(w[t:]) sum w[t:] w t: t ans=abs(sum(w[:t])-sum(w[t:])) ans abs(sum(w[:t])-sum(w[t:])) abs sum(w[:t])-sum(w[t:]) sum(w[:t]) sum w[:t] w :t t sum(w[t:]) sum w[t:] w t: t print(ans) print ans main() main def main():
  n=int(input())
  w = list(map(int,input().split()))
  ans=abs(sum(w[:1])-sum(w[1:]))
  for t in range(2,n+1):
    if ans>abs(sum(w[:t])-sum(w[t:])):
      ans=abs(sum(w[:t])-sum(w[t:]))
  print(ans) def main():
  n=int(input())
  w = list(map(int,input().split()))
  ans=abs(sum(w[:1])-sum(w[1:]))
  for t in range(2,n+1):
    if ans>abs(sum(w[:t])-sum(w[t:])):
      ans=abs(sum(w[:t])-sum(w[t:]))
  print(ans) main
import math
def main():
  n=int(input())
  w = list(map(int,input().split()))
  ans=abs(sum(w[:1])-sum(w[1:]))
  for t in range(2,n+1):
    if ans>abs(sum(w[:t])-sum(w[t:])):
      ans=abs(sum(w[:t])-sum(w[t:]))
  print(ans)

main()