#include <bits/stdc++.h>
using namespace std;
int a[500001];
int main() {
  int k, n, left = 0, right, ans = 0, t;
  scanf("%d%d", &k, &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  right = a[n - 1];
  while (left < right - 1) {
    int mid = (left + right) / 2;
    t = 0;
    for (int i = 1; i < n; i++) {
      if (a[i] - a[i - 1] <= mid) {
        t++;
        i++;
      }
      if (t >= k) break;
    }
    if (t < k)
      left = mid;
    else
      right = mid;
  }
  t = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] - a[i - 1] < right) {
      if (i == n - 2)
        ans += min(a[i + 1] - a[i], a[i] - a[i - 1]);
      else
        ans += a[i] - a[i - 1];
      t++;
      i++;
    } else if (a[i] - a[i - 1] == right) {
      if (a[i + 1] - a[i] < right && a[i + 2] - a[i + 1] > right) {
      } else
        i++;
    }
  }
  ans += (k - t) * right;
  printf("%d", ans);
  return 0;
}
