var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/g);
var a = input[1].split(/\s/g).map(function(s){return s - 0;});
var result = 999999999;
for (var i = 1; i < a.length; i++) {
    var x = a.slice(0, i).reduce(function(sum, n){return sum + n;});
    var y = a.slice(i).reduce(function(sum, n){return sum + n;});
    result = Math.min(result, Math.abs(x - y));
}
console.log(result);