inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
N = inp.shift() * 1
l = inp.shift().split(' ')
sum = 0
a = []
for (i=0; i<N; i++) {
    sum += l[i] * 1
    a[i] = sum
}
min = Infinity
for (i=0; i<N-1; i++) {
    d = Math.abs(a[i] - (sum - a[i]))
    if (min > d) {
        min = d
    } 
}
console.log(min)