#include <bits/stdc++.h>
using namespace std;
long long ans = 4e18;
int k;
multiset<pair<long long, pair<long, long> > > seta;
void dyn(long long sum, int cnt, map<long long, bool> used) {
  if (cnt == k) {
    ans = min(ans, sum);
    return;
  }
  for (set<pair<long long, pair<long, long> > >::iterator it = seta.begin();
       it != seta.end(); ++it) {
    if (used[(*it).second.first] || used[(*it).second.second]) continue;
    used[(*it).second.first] = true;
    used[(*it).second.second] = true;
    dyn((*it).first + sum, cnt + 1, used);
    used[(*it).second.first] = false;
    used[(*it).second.second] = false;
    break;
  }
  return;
}
map<long long, bool> used;
int main() {
  int i, j, n;
  cin >> k >> n;
  long long a[n];
  for (i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  if (n == 2) seta.insert(make_pair(a[1] - a[0], make_pair(a[1], a[0])));
  for (i = 1; i < n - 1; ++i) {
    seta.insert(make_pair(a[i] - a[i - 1], make_pair(a[i], a[i - 1])));
    seta.insert(make_pair(a[i + 1] - a[i], make_pair(a[i + 1], a[i])));
  }
  i = 0;
  for (set<pair<long long, pair<long, long> > >::iterator it = seta.begin();
       i < 3 * k, it != seta.end(); ++i, ++it) {
    used[(*it).second.first] = true;
    used[(*it).second.second] = true;
    dyn((*it).first, 1, used);
    used[(*it).second.first] = false;
    used[(*it).second.second] = false;
  }
  cout << ans;
}
