object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val W = Array.fill(N)(sc.nextInt())

    var S1 = W.head
    var S2 = W.tail.sum
    var diff = Math.abs(S1 - S2)
    var i = 1
    while (i < N - 1) {
      val v = W(i)
      S1 += v
      S2 -= v
      diff = Math.min(diff, Math.abs(S1 - S2))
      i += 1
    }
    println(diff)
  }

}
