#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  
  vector<int> X(m), sub(m-1);
  for (int i = 0; i < m; i++) cin >> X.at(i);
  sort(X.begin(), X.end());
  for (int i = 0; i < m-1; i++) sub.at(i) = X.at(i+1) - X.at(i);
  sort(sub.begin(), sub.end());
  for (int i = 0; i < m-n; i++) ans += sub.at(i);
  cout << ans << endl;
}