import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val weights = readLine.trim.split(' ').map(_.toInt)
  println(
    (1 until n).map{t ⇒ ((0 until t).map(weights).sum - (t until n).map(weights).sum).abs}.min
  )
}
