fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val sum = a.sum()
    var subsum = 0L
    a.take(n-1).map {
        subsum += it
        Math.abs(sum - 2 * subsum)
    }.min().let(::println)
}