object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val as = Array.fill(n)(sc.nextLong)
  var i = as.sum
  var min = Integer.MAX_VALUE.toLong
  as.drop(1).reverseIterator.foreach { a =>
    i -= a * 2
    if (math.abs(i) < min) min = math.abs(i)
  }
  println(min)
}