fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val a= readLine()!!.split(" ").map{it.toLong()}
    var x=a[0]
    var y=a.sum()-a[0]
    var diff=Math.abs( x-y )
    for(i in 1..n-2){
        x+=a[i]
        y-=a[i]
        diff=Math.min(diff, Math.abs(x-y))
    }
    println(diff)
}