function main(input) {
    const args = input.split('\n');
    const Args = args[0].split(' ')
  	const N = parseInt(Args[0], 10)
    const M = parseInt(Args[1], 10)
    const L = args[1].split(' ').map(Number).sort(A)
  	var S = B(L,N)
    
    if(N>=M){
    	console.log(0)
    }else{
    	 console.log(S)
    }
    
}

var A = (a,b)=>{
  if( a > b ) return -1;
        if( a < b ) return 1;
        return 0;
}

var B = (l,n)=>{
    var a = []
    var s = 0
  	for(var i =0;i<l.length-1;i++){
    	a[i] = l[i] - l[i+1]
    }
    a.sort(A)
    for(var j = n-1;j<a.length;j++){
    	s += a[j]
    }
  	return s
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));