"use strict";

function Main(input)
{
    // console.log(input);
    let arr = input.split('\n');
    let N = arr.shift();
    // console.log(N);
    // console.log(arr);
    let W = arr[0].split(' ').map(function(a) {
        return parseInt(a, 10);
    });
    
    let min = Math.abs(sum(W, 0, 1) - sum(W, 1, N));
    for(let T = 2; T < N; T++)
    {
        let diff = Math.abs(sum(W, 0, T) - sum(W, T, N));
        min = diff < min ? diff : min;
    }
    
    let result = min;
    console.log(result);
    return result;
}

function sum(W, from, to)
{
    let total = 0;
    for(let i = from; i < to; i++)
    {
        total += W[i];
    }
    return total;
}

// Main(require("fs").readFileSync("Task02_input01.txt", "utf8"));
Main(require("fs").readFileSync("/dev/stdin", "utf8"));