function Main(input) {
    var lines = input.split("\n");
    var n = lines[1].split(" ").length
	var As = lines[1].split(" ").map(el => Number(el));
    var cumulativeSum = []
    cumulativeSum.push(As[0])
    As.reduce((pre, cur) => { cumulativeSum.push(pre + cur); return pre+cur})
    var diffs = []
    for(var i = 0; i < n - 1; i++) {
        diffs.push(Math.abs(cumulativeSum[i] - (cumulativeSum[n - 1] - cumulativeSum[i])))
    }
    console.log(Math.min(...diffs))
}

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