#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using  namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  ll X[M];
  rep(i, M) cin >> X[i];
  sort(X, X+M);
  ll dif[M-1];
  rep(i, M-1) dif[i] = X[i+1] - X[i];
  sort(dif, dif + M -1);
  ll ans = 0;
  rep(i, M-N) ans += dif[i];
  cout << ans << endl;
  return 0;
}