log = console.log;


function max(arr){
  return Math.max(...arr);
}
var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin.split("\n");
var N = Number(lines[0].split(" ")[0]);
var M = Number(lines[0].split(" ")[1]);
var XS = lines[1]
  .split(" ")
  .map(v => ~~v)
  .sort((a, b) => a - b);

if (N >= M) {
  log(0);
} else {
  LS = [];
  for (var i = 0; i < XS.length - 1; i++) {
    var L = XS[i + 1] - XS[i];
    LS.push(L);
  }

  LS_SUM = LS.reduce((a,b)=>a+b)
  for(var i = 0; i < N-1; i++){
    LS_MAX = max(LS)
    LS_SUM -= LS_MAX
    LS.splice(LS.indexOf(LS_MAX),1)
  }
  log(LS_SUM)
  
}
