object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, M = sc.nextInt()
    val X = Array.fill(M)(sc.nextInt()).sorted

    if (N >= M)
      println(0)
    else
      println(X(M-1) - X(0) - X.sliding(2).map(_.reduce((a, b) => b - a)).toSeq.sorted(Ordering.Int.reverse).take(N - 1).sum)
  }

}
