fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val W = readLine()!!.split(" ").map { it.toInt() }

    var min = Int.MAX_VALUE
    (1..(N-1)).forEach { T ->
        val groupA = W.filterIndexed { index, i ->  index <= T }
        val groupB = W.filterIndexed { index, i ->  index > T }


        min = Math.min(min, Math.abs(groupA.sum() - groupB.sum()))
    }
    println(min)
}