#include <bits/stdc++.h>
using namespace std;
mt19937 Random(long long(time(0)));
const long long INF = 1e9 + 10;
const long long MOD = 1e9 + 7;
const long long P = 239017;
const long long BINF = 1e18 + 10;
const long double EPS = 1e-9;
vector<long long> arr;
long long n;
pair<long double, long long> get_min(pair<long double, long long> a,
                                     pair<long double, long long> b) {
  if (a.first < b.first) {
    return a;
  }
  if (b.first < a.first) {
    return b;
  }
  return max(a, b);
}
pair<long double, long long> check(long double penalty) {
  vector<pair<long double, long long> > dp(n);
  for (long long i = 2; i < n; i++) {
    dp[i] = {BINF, BINF};
  }
  dp[1] =
      get_min(make_pair(long double(0), long long(0)),
              make_pair(long double(arr[1] - arr[0] - penalty), long long(1)));
  for (long long i = 2; i < n; i++) {
    dp[i] =
        get_min(dp[i - 1], {dp[i - 2].first + (arr[i] - arr[i - 1] - penalty),
                            dp[i - 2].second + 1});
  }
  return dp[n - 1];
}
inline void source() {
  long long k;
  cin >> k >> n;
  arr.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort((arr).begin(), (arr).end());
  long double l = 0, r = 1e12 + 10;
  for (long long it = 0; it < 200; it++) {
    long double mid = (l + r) / 2.0;
    if (check(mid).second >= k) {
      r = mid;
    } else {
      l = mid;
    }
  }
  pair<long double, long long> kek = check(r);
  cout << round(kek.first + k * r);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  source();
  return 0;
}
