fun main (args : Array<String>) {
	val (n, m) = readLine()!!.split(" ")
	val N : Int = n.toInt()
	val M : Int = m.toInt()
	val x = readLine()!!.split(" ")
	var list1 : MutableList<Int> = mutableListOf()
	var list2 : MutableList<Int> = mutableListOf()
	var result : Int = 0
	if (N >= M) {
		return println("0")
	}
	for (i in x) {
		list1.add(i.toInt())
	}
	list1.sort()
	for (i in 1..M - 1) {
		list2.add(list1[i] - list1[i - 1])
	}
	list2.sort()
	for (i in 0..N - 2) {
		list2.removeAt(list2.size - 1)
	}
	//println("${list2}")
	for (i in 0..list2.size - 1) {
		result += list2[i]
	}
	println("${result}")
	
}