import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val x = (1..m).map { sc.nextInt() }.sorted()


  if (n >= m) {
    println(0)
    return
  }

  val length = x[m-1] - x[0]

  val l = (1..m-1).map { x[it] - x[it-1] }.sorted().reversed()
  val last = l.subList(0, n-1).sum()

  println(length - last)

}