input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0] * 1
M = line[1] * 1
line = lines.shift().split(' ')
if (line.length <= N) {
    ans = 0
} else {
    x = line.sort((a,b) => a - b) 
    d = []
    for (i=0;i<M-1;i++) {
        d[i] = x[i+1] - x[i]
    }
    d = d.sort((a,b) => a - b)
    while(--N) {
        d.pop()
    }
    sum = 0
    for (i=0;i<d.length;i++) {
        sum += d[i]
    }
    ans = sum
}
console.log(ans)