input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
W = lines.shift().split(' ')

s1 = 0
sum = 0
for (i=0; i < N; i++) {
    sum += W[i] * 1
}

abs = 100 * 100
for (i=0; i < N; i++) {
    s1 += W[i] * 1
    diff = Math.abs(s1 - (sum - s1))
    if (abs > diff) {
        abs = diff
    } 
}

console.log(abs)
