import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    const N = tmp[0], M = tmp[1];
    auto xs = readln.split.to!(long[]).sort!((a,b) => a < b).array;
    const d = iota(M-1).map!(i => xs[i+1] - xs[i]).array.sort!((a,b) => a < b).array;
    if (d.length < N) {
        writeln(0);
    } else {
        d[0..N+1].sum.writeln;
    }
}
