const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const output = () => {
  if (m === 1) {
    console.log(0);
  } else if (n >= m) {
    console.log(0);
  } else {
    const sorting = (arr) => {
      return arr.sort((a,b) => a - b);
    };

    const n = Number(input.split('\n')[0].split(' ')[0]);
    const m = Number(input.split('\n')[0].split(' ')[1]);

    const numberlist = input.split('\n')[1].split(' ').map(i => Number(i));

    const sorted = sorting(numberlist);

    var minuslist = [];

    for (var i = 0; i < m-1; i++) {
      minuslist.push(sorted[i+1]-sorted[i]);　//m-1個の配列
    }

    const maxarr = sorting(minuslist).slice(m - n);

    var maxarrsum = maxarr.reduce((p, c) => {
      return p + c;
    });

    var answer = Number(sorted[m-1]) - Number(sorted[0]) - maxarrsum;

    console.log(answer);
  }
};
output();
