'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => v.split(' ').map(Number))

  const n = input[0]
  const cards = input[1]
  const total = cards.reduce((a, b) => a + b)
  let min = Number.MAX_SAFE_INTEGER
  let xx = 0
  for (let i = 0; i < n - 1; i++) {
    xx += cards[i] * 2
    const tmp = Math.abs(total - xx)
    min = Math.min(min, tmp)
  }
  console.log(min)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
