fun abs(n: Int) = if (n > 0) n else -n

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ws = readLine()!!.split(" ").map { it.toInt() }
    println((0 until n).map { abs(ws.take(it).sum() - ws.drop(it).sum()) }.min()!!)
}