object Main extends App {
	val N = scala.io.StdIn.readInt
	val L = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	val a = new Array[Long](N)

	a(0) = L(0)

	for(i<-1 until N){
		a(i) = a(i-1) + L(i)
	}
	
	var test = (2*a(0)-a(N-1)).abs

	for(i<-1 until N-1){
		val temp = (2*a(i)-a(N-1)).abs

		if(temp < test) test = temp
	}

	println(test)

}
