program abc129b
  implicit none
  integer :: n, t, s1, s2, ans, diff
  integer, allocatable :: w(:)

  read(*,*) n
  allocate(w(n))
  read(*,*) w(:)

  ans = sum(w)
  diff = 0
  
  do t = 1, n-1
    s1 = sum(w(1:t))
    s2 = sum(w(t+1:n))
    diff = abs(s1-s2)
    if (ans>diff) ans = diff
  enddo

  print *, ans

end program abc129b
