program main
  implicit none
  integer(8) i,N,W(100),S,AllW,Sst
  read(*, *) N
  read(*, *) (W(i), i = 1,N)
  AllW = 0
  do i = 1,N
    AllW = AllW + W(i)
  end do
    
  S = 0
  do i = 1,N
    S = S + W(i)
    if (AllW-2*S < 0) then
      exit
    else
      Sst = S
    end if
  end do

  write(* ,*) min(AllW-2*Sst,abs(AllW-2*S))
end program main
