object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = List.fill(n)(sc.nextInt())
  val sumL = a.scanLeft(0)(_ + _).init.tail
  val sumR = a.scanRight(0)(_ + _).init.tail
  val ans = sumL.zip(sumR).map{case (l, r) => (l - r).abs}.min
  println(ans)
}
