function Main(input) {
    input = input.trim().split("\n");
    var N = parseInt(input[0],10);
    tmp = input[1].split(" ");
    var W = [];
    for(var i = 0; i < tmp.length; i++){
        W[i] = parseInt(tmp[i],10);
    }
    var sum = 0;
    for(var i = 0; i < W.length; i++){
        sum += W[i];
    }

    var temp = 0;
    for(var i = 0; i < W.length - 1; i++){
        temp += W[i];
        if(temp >= sum/2){
            break;
        };
    }

    console.log(Math.abs(sum - 2*temp));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));