import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val X = Array.fill(M)(sc.nextInt).sorted
    val d = (for (i <- 1 until X.length) yield X(i) - X(i - 1)).sorted

    d.take(M - N).sum.toString
  }
}
