import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val M = sc.nextInt()
    if (N >= M) {
        println(0)
        return
    }

    val X = IntArray(M){0}
    for (i in 0 until M) {//MをN個に区切る
        val x = sc.nextInt()
        X[i] = x
    }
    X.sort()

    val sub = IntArray(M-1){0}
    for (i in 0 until M-1) {
        sub[i] = X[i+1] - X[i]
    }
    sub.sort()
    println(sub.dropLast(N-1).sum())//ギャップが大きいところをなくすように区切る

    // 0 1 2 3 4 5
    //  1 1 1 1 1
    // 1 2 10 12 14
    //  1 8  2  2
}