"use strict";

function Main(input)
{
    // console.log(input);
    let arr = input.split('\n');
    let indices = arr.shift();
    console.log(indices);
    console.log(arr);
    arr = arr[0].split(' ').map(function(a) {
        return parseInt(a, 10);
    });
    

    let differences = [];
    for(let T = 2; T < indices; T++)
    {
        let S1 = 0;
        let S2 = 0;
        for(let i = 0; i < arr.length; i++)
        {
            if(i < T) S1 += arr[i];
            else if( i >= T) S2 += arr[i];
        }
        console.log("Difference is: " + Math.abs(S1 - S2) + " from " + S1 + " and " + S2);
        differences.push(Math.abs(S1 - S2));
    }
    
    let result = Math.min(...differences);
    console.log(result);
    return result;
}

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