import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val w = (0 until n).map { 
        sc.nextInt()
     }

     abc129b(n, w)
}

fun abc129b(n: Int, w: List<Int>) {
    var list: MutableList<Int> = mutableListOf()
    for (i in 1..n) {
       var s1 = w.take(i).sum()
       var s2 = w.takeLast(n - i).sum()
       var abs = Math.abs(s1 - s2)
       list.add(abs)
    }
    var ans = list.min()

    println(ans)
}
