import java.util.Scanner

object Main{
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit ={
    val n = sc.nextInt
    val m = sc.nextInt
    val x = List.fill(m)(sc.nextInt).sorted
    if(n >= m) println(0)
    else{
      // m > 1
      val d = (1 to (m - 1)).foldLeft(Seq.empty[Int]){ (seq, i) =>
        seq :+ ( x(i) - x(i - 1) )
      }.sorted
      val res = (0 to (m - n - 1)).foldLeft(0){ (r, i)=>
        r + d(i)
      }

      println(res)

    }
  }
}