
function Main(input) {
    var N = parseInt(input[0], 10);
    var W = input.slice(1).map(w => parseInt(w, 10));

    var result = 0;
    var smallSum = 0;
    var bigSum = 0;
    var diff = 0;

    for (var i = 0; i < W.length; i++) {
        smallSum = 0;
        bigSum = 0;
        for (var j = 0; j < W.length; j++) {
            if (i >= j) {
                smallSum += W[j];
            } else {
                bigSum += W[j];
            }
        }
        diff = Math.abs(smallSum - bigSum);
        if (i === 0) {
            result = diff;
        } else {
            result = result > diff ? diff : result;
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));