fun main(args: Array<String>) {
    val INF_MAX = 1000000007
    val N = readLine()!!.toInt()
    val W = readLine()!!.split(" ").map(String::toInt)
    var S1 = 0
    var S2 = W.sum()
    var result = INF_MAX
    W.forEach { w ->
        S1 += w
        S2 -= w
        result = Math.min(result, Math.abs(S1 - S2))
    }
    println(result)
}