object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n, m = in.nextInt
  val xs = Array.fill(m)(in.nextInt).sorted
  val spaces = xs.sliding(2).map(s => s.last - s.head).toList
  println(spaces.sorted.reverse.drop(n - 1).sum)
}