import scala.io.StdIn._

object Main extends App {

  val Array(n,m) = readLine().split(" ").map(_.toInt)
  val X = readLine().split(" ").map(_.toLong)

  def solve() = {
    val sorted = X.sorted
    (0 until m-1).map { i =>
      sorted(i+1) - sorted(i)
    }.sorted(Ordering[Long].reverse).drop(n-1).sum
  }

  println(solve())

}

