fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val W = readLine()!!.split(" ").map(String::toInt)
    var min = Integer.MAX_VALUE
    for (T in 1 until N) {
        val S1 = W.subList(0, T).sum()
        val S2 = W.subList(T, W.size).sum()
        min = Math.min(Math.abs(S1 - S2), min)
    }
    println(min)
}