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

    var ans = Int.MAX_VALUE

    for ( i in 1 until n){

        val left = inputs.subList(0, i)
        val right = inputs.subList(i, n)
        ans = Math.min(ans, Math.abs(left.sum() - right.sum()))
    }


    println(ans)

}