"use strict"
function main(arg) {
    var W = arg.trim().split("\n")[1].split(" ").map(Number)
    var N = W.length
    var ans = Number.MAX_SAFE_INTEGER
    for (var T = 1; T < N; T++) {
        var s1 = 0
        var s2 = 0
        for (var j = 0; j < N; j++) {
            var w = W[j]
            if (j <= T) {
                s1 += w
            } else {
                s2 += w
            }
        }
        ans = Math.min(ans, Math.abs(s1 - s2))
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));