"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), M = cin.getInt();
    let A = cin.getIntArray(M);
    let P = new Array(M-1);
    A.sort((a, b) => a - b);
    let ans;
    if (N == 1) ans = A[M-1] - A[0];
    else if (N == M) ans = 0;
    else {
        for (let n = 0; n < M-1; n++) P[n] = A[n+1] - A[n];
        P.sort((a, b) => b - a);
        for (let n = 0; n < N-1; n++) P.shift();
        ans = P.reduce((ac, v) => ac + v, 0);
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));