#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
  int n,m; cin>>n>>m;
  if(n>=m){cout<<0; return 0;}
  
  int M[m]; int D[m-1];
  for(int i=0;i<m;i++){cin>>M[i];}
  sort(M,M+m);
  
  for(int i=0;i<m-1;i++){D[i]=M[i+1]-M[i];}
  sort(D,D+m-1);
  
  ll sum=0;
  for(int i=0;i<m-n;i++){sum=sum+(ll)D[i];}
  cout<<sum;
  
  return 0;
}