import scala.io.{StdIn => in}

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

  var res = Int.MaxValue
  for(i <- 1 until n) {
    val a = w.take(i).sum
    val b = w.drop(i).sum
    if((a-b).abs < res) res = (a-b).abs
  }

  val ans = res
  println(ans)
}