private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val X = readLine()!!.split(" ").map { it.toInt() }

    val sortedX = X.sorted()
    val s = (0 until M - 1).map { sortedX[it + 1] - sortedX[it] }

    try {
        println(Math.max(0, s.sorted().reversed().drop(N - 1).sum()))
    } catch (ex: Exception) {
        println("0")
    }
}