import java.util.*

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

    val res = X.last() - X.first()
    val Y = Array(M - 1) { X[it + 1] - X[it] }.sortedDescending().take(N - 1).sum()

    println(res - Y)
}
