program main
    implicit none
    integer :: n, w(100), s1, s2, i, j, k, ms
    

    read(*,*)n
    read(*,*)(w(i),i = 1, n)
    ms = 1000000
    
    do j = 1, n-1
      s1 = 0
      s2 = 0
      do i = 1, j
        s1 = s1 + w(i)
      end do
      do i = j+1, n
        s2 = s2 + w(i)
      end do
      if (ms > abs(s1 -s2)) then
        ms = abs(s1-s2)
      end if
    end do

    write(*,*)ms
end program main