"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

let lines = [];
var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", line => {
  lines.push(line.split(/\s/).map(i => parseInt(i)));
});

reader.on("close", () => {
  let firstLine = lines.shift();
  let n = firstLine[0], m = firstLine[1];
  if (m == 1) {
    console.log(0);
    return;
  }
  let x = lines.shift().sort((a, b) => a - b);
  let a = [];
  let indexArr = [];
  let ans = 0;
  for (let i = 0; i < m - 1; i++) {
    a.push(x[i + 1] - x[i]);
  }
  for (let i = 0; i < n - 1; i++) {
    let max = Math.max(...a);
    let index = a.indexOf(max);
    indexArr.push(index);
    a[index] = 0; 
  }
  
  for (let i = 0; i < n - 1; i++) {
    let start = 0;
    if (indexArr[0] == 0) {
      indexArr.shift();
      continue;
    }
    ans += a.splice(start, indexArr[0] - start).reduce(((total, num) => total + num)); 
    indexArr.shift();
  }

  console.log(ans + a.reduce((total, num) => total + num));
  
});
