let N = Int(readLine()!)!
let a = readLine()!.characters.split(" ").map{Int(String($0))!}
var x = a[0]
var y = a.reduce(0){$0+$1} - a[0]
var ans = abs(x-y)
for i in 1..<N-1 {
    x += a[i]
    y -= a[i]
    ans = min(abs(x-y), ans)
}
print(ans)