"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = ~~arg[0].split(" ")[0];
    const M = ~~arg[0].split(" ")[1];
    const X = arg[1].split(" ").map(n=>~~n).sort((a,b)=>a-b);
    
    // ソートして、差の大きい順で分ける
    let diffs = [];
    
    for(let i in X) {
        if(X[~~i+1] - X[i]) {
            diffs.push(X[~~i+1] - X[i]);
        }
    }
    
    if(!diffs.length) {
        console.log(0);
        return;
    }
    
    diffs.sort((a,b)=>b-a);
    let answer = diffs.reduce((m,n)=>m+n);

    for(let i=0; i<N-1; i++) {
        answer -= diffs[i];
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));