#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
int N, K, memo[500009];
long long int t[500009];
double dp[500009];
int solve(double mid) {
  dp[N] = dp[N + 1] = 0;
  for (int i = N - 1; i >= 0; --i) {
    double a = dp[i + 1], b = dp[i + 2] + t[i] - mid;
    dp[i] = min(a, b);
    memo[i] = b < a;
  }
  int cur = 0, cnt = 0;
  while (cur < N) {
    if (memo[cur])
      cnt++, cur += 2;
    else
      cur++;
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  scanf("%d%d", &K, &N);
  for (int i = 0; i < N; ++i) scanf("%lld", &t[i]);
  sort(t, t + N);
  N--;
  for (int i = 0; i < N; ++i) t[i] = t[i + 1] - t[i];
  double l = 0, r = 1000000000;
  for (int i = 0; i < 60; ++i) {
    double mid = (l + r) / 2;
    if (solve(mid) <= K)
      l = mid;
    else
      r = mid;
  }
  printf("%lld\n", (long long int)round(dp[0] + K * l));
}
