#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N = 500005;
const double PI = acos(-1.0);
const double eps = 1e-9;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
int k, n, num[N], t[N], ans, l = 0, r = 1e9, mid;
long long dp[N], ans0;
bool check(int C) {
  dp[1] = num[1] = 0;
  for (int i = (2); i <= (n); ++i) {
    dp[i] = dp[i - 1], num[i] = num[i - 1];
    if (dp[i - 2] + t[i] - t[i - 1] - C <= dp[i])
      dp[i] = dp[i - 2] + t[i] - t[i - 1] - C, num[i] = num[i - 2] + 1;
  }
  return num[n] >= k;
}
int main() {
  scanf("%d%d", &k, &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", &t[i]);
  sort(t + 1, t + n + 1);
  while (l <= r) {
    mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, ans0 = dp[n], r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%I64d\n", ans0 + (long long)ans * k);
  return 0;
}
