output_description: Find the minimum number of moves required to achieve the objective.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      X_1 X_2 ... X_M
attempt: #define _USE_MATH_DEFINES
  #include <iostream>
  #include <algorithm>
  #include <string>
  #include <cmath>
  #include <ctype.h>
  #include <map>
  #include <vector>
  #include <stdlib.h>
  #define REP(i,n) for(int i=0;i<(int)n;i++)
  #define REP1(j,n) for(int j=0;j<(int)n;j++)
  #define REPD(i,n) for(int i=n;i>=0;i--)
  #define REPD1(j,n) for(int j=n;j=>0;j--)
  #define REPS(i,n) for(int i=1;i<=(int)n;i++)
  #define REPS1(j,n) for(int j=1;j<=(int)n;j++)
  #define rep(i,a,n) for(int i=a;i<=(int)n;i++)
  #define SZ(x) ((int)(x).size())	//size() unsigned -> int
  #define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())
  
  using namespace std;
  typedef long long ll;
  
  int main(void) {
  	int n, m,x[10005];
  	int max_sum=0;
  	cin >> n >> m;
  	REP(i, m)cin >> x[i];
  	if (n >= m) cout << "0" << endl;
  	else {
  		sort(x, x + m);
  		int diff[10005];
  		REP(i, m - 1) { diff[i] = x[i + 1] - x[i]; }
  		sort(diff, diff + (m - 1), std::greater<int>());
  		REP(i, n - 1) { max_sum += diff[i]; }
  		cout << (x[m - 1] - x[0]) - max_sum << endl;
  	}
  	
  	return 0;
  }
  
  
problem_description: Statement
  
  We will play a one-player game using a number line and N pieces.
  
  First, we place each of these pieces at some integer coordinate.
  
  Here, multiple pieces can be placed at the same coordinate.
  
  Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
  these pieces, by repeating the following move:
  
  **Move** : Choose a piece and let x be its coordinate. Put that piece at
  coordinate x+1 or x-1.
  
  Note that the coordinates where we initially place the pieces are already
  regarded as visited.
  
  Find the minimum number of moves required to achieve the objective.
samples: [{"input": "2 5\n    10 12 1 2 14", "output": "5\n    \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n  * Initially, put the two pieces at coordinates 1 and 10.\n  * Move the piece at coordinate 1 to 2.\n  * Move the piece at coordinate 10 to 11.\n  * Move the piece at coordinate 11 to 12.\n  * Move the piece at coordinate 12 to 13.\n  * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n    -10 -3 0 9 -100 2 17", "output": "19\n    \n\n* * *"}, {"input": "100 1\n    -100000", "output": "0"}]