import java.util.Scanner

object Main {
  def main(args:Array[String]) = {
    val sc = new Scanner(System.in)
    val N,M = sc.nextInt()
    val listX = List.fill(M)(sc.nextInt())
    val s = listX.sortWith((a, b) => a < b)
    val g = s.zip(s.tail).map{
      case (a, b) => (b - a).abs
    }.sortWith((a,b) => a > b).drop(N - 1).sum
    println(g)
  }
}