object Main{
  def main(args: Array[String]){
      	val ct = io.StdIn.readLine.split(" ").map(_ .toInt)
    	val dots = io.StdIn.readLine().split(" ").map(_ .toInt).sorted.toList
    	val diffs = (0 until ct(1)-1).map(i => dots(i+1) - dots (i)).sorted;
    	val dist = dots(ct(1)-1) - dots(0)
        print((dist- diffs.takeRight(ct(0)-1).sum).toString)
  }
}