
object Main extends App {
	val n = scala.io.StdIn.readInt
	val w = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	val p = new Array[Int](n)

	p(0) = w(0)

	for(i<-1 until n){
		p(i) = p(i-1) + w(i)
	}

	val sum_w = w.sum
	var ans = Int.MaxValue

	for(i<-1 until n-1){
		ans = math.min(ans, math.abs(sum_w - 2*p(i)))
	}

	println(ans)

}