
'use strict'

function main(input) {
  input = input.split('\n')
  input[0] = input[0].split(' ').map(v => ~~v)
  const n = input[0][0]
  const m = input[0][1]
  if (n >= m) {
    console.log(0)
    return
  }

  const x = input[1]
    .split(' ')
    .map(v => ~~v)
    .sort((a, b) => a - b)

  const map = [0]
  for (let i = 1; i < m; i++) {
    map.push(x[i] - x[i - 1])
  }
  map.sort((a, b) => a - b)
  let sum = map.slice(0, m - n + 1).reduce((a, c) => a + c)

  console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
