program main
  implicit none
  integer :: n, i, s1, s2, res
  integer, allocatable :: w(:)
  read (*, *) n
  allocate (w(n))
  read (*, *) w(:)
  res = 99999999
  do i = 1, n - 1
    s1 = sum(w(1:i))
    s2 = sum(w(i + 1:n))
    res = min(res, abs(s1 - s2))
  end do
  write (*, "(i0)") res
end program main
