function main(input){
    var input = input.split('\n');
    var n = input[0].split(' ')[0]
    var x = input[1].split(' ').map((n)=>Number.parseInt(n,10)).sort((a,b) => a<b ? 1 : -1);
    var y = x.slice(1, x.length);
    x.pop();
    var distances = [];
    for ( var i=0; i<x.length; i++){
        distances.push(x[i] - y[i])
    }
    distances.sort((a,b) => a<b ? 1 : -1);
    var list = distances.slice(n-1,distances.length)
    console.log(list.reduce((a,b) => a+b));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
