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

    var absMin = Int.MAX_VALUE
    for (i in 1 until n) {
        val left = wList.subList(0, i).sum()
        val right = wList.subList(i, n).sum()
        val abs = Math.abs(left - right)
        if (abs < absMin) absMin = abs
    }

    println(absMin)
}
