#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  bool f = 1;
  char s = getchar();
  while ((s < '0' || s > '9') && s > 0) {
    if (s == '-') f ^= 1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') x = (x << 1) + (x << 3) + s - '0', s = getchar();
  return f ? x : -x;
}
int n, k;
long long s[500005], D, cnt;
struct itn {
  long long x;
  int y;
  itn() {}
  itn(long long X, int Y) { x = X, y = Y; }
  inline bool operator<(const itn& b) const {
    if (x != b.x)
      return x < b.x;
    else
      return y < b.y;
  }
  inline itn operator+(const itn& b) { return itn(x + b.x, y + b.y); }
} dp[500005];
inline bool check(int mid) {
  D = mid, dp[0] = itn(0, 0);
  for (int i = 1; i <= n; i++) {
    dp[i] = min(itn(0, 0), dp[i - 1]);
    if (i > 1) dp[i] = min(dp[i], dp[i - 2] + itn(s[i] - s[i - 1] - D, 1));
  }
  return dp[n].y > k;
}
signed main() {
  k = read(), n = read();
  for (int i = 1; i <= n; i++) s[i] = read();
  sort(s + 1, s + 1 + n);
  long long l = 0, r = 1e10, mid;
  while (l < r) {
    mid = (l + r + 1) >> 1;
    if (check(mid))
      r = mid - 1;
    else
      l = mid;
  }
  check(l);
  printf("%lld\n", dp[n].x + D * k);
  return 0;
}
