import scala.io.StdIn

object Main extends App {
  val N = StdIn.readInt()
  val Ws = StdIn.readLine().split(" ").map(_.toInt)

  val abss =
  for (t <- 1 to N) yield {
    val sum1 = Ws.take(t).sum
    val sum2 = Ws.drop(t).sum
    Math.abs(sum1 - sum2)
  }

  println(abss.min)

}