log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin.split("\n");
var N = lines[0].split(" ")[0];
var M = lines[0].split(" ")[1];
var XS = lines[1].split(" ");

if (N >= M) {
  log(0);
} else {
  XS = XS.sort((a, b) => {
    return +a - +b;
  });

  X1 = XS[0];
  XM = XS[XS.length - 1];
  range = XM - X1;

  LS = [];
  for (var i = 0; i < XS.length - 1; i++) {
    var L = XS[i + 1] - XS[i];
    LS.push(L);
  }

  var move = 0
  for(var i = 0; i < N-1; i++){
    LS_MAX = max(LS)
    LS.splice(LS.indexOf(LS_MAX),1)
  }
  log(sum(LS))
}

function sum(arr) {
  return arr.reduce(function(prev, current, i, arr) {
    return +prev + +current;
  });
}

function max(arr){
  return Math.max(...arr);
}

function min(arr){
  return Math.min(...arr);
}