function main(input) {
    var N = input[0].split(" ")[0]-0;
    var sum = 0;
    var list = input[1].split(" ").map(v=>{
        sum += v-0;
        return v-0;
    });
    var tmpsum = 0;
    var ans = Number.MAX_SAFE_INTEGER;
    for(var i=0;i<N-1;i++){
        tmpsum+=list[i];
        ans = Math.min(Math.abs(tmpsum-(sum-tmpsum)),ans);
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
