#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  int a[M];
  for (int i = 0; i < M; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a, a + M);
  int b[M - 1];
  for (int i = M - 1; i > 0; --i) {
    b[i - 1] = a[i] - a[i - 1];
  }
  sort(b, b + M);
  if (N >= M)
    cout << 0 << endl;
  else {
    int sum = 0;
    for (int i = 0; i < M - N; ++i) {
      sum += b[i];
    }
    cout << sum << endl;
  }
}
