#include <bits/stdc++.h>
using namespace std;
int xm[4] = {-1, 1, 0, 0};
int ym[4] = {0, 0, -1, 1};
const int MOD = 1e9 + 7;
const int MAXN = 5e5 + 5;
const long long POW = 9973;
int dp[13001][5001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k, n;
  cin >> k >> n;
  int ar[n];
  for (int i = 0; i < n; i++) cin >> ar[i];
  sort(ar, ar + n);
  vector<int> v(n, 0);
  vector<pair<int, int>> dst;
  for (int i = 1; i < n; i++) {
    dst.push_back(make_pair(ar[i] - ar[i - 1], i - 1));
  }
  sort(dst.begin(), dst.end());
  v[0] = 1;
  v[n - 1] = 1;
  for (int i = 0; i < 2 * k && i < dst.size(); i++) {
    v[dst[i].second] = 1;
    v[dst[i].second + 1] = 1;
  }
  vector<int> a;
  for (int i = 0; i < n; i++) {
    if (v[i]) a.push_back(ar[i]);
  }
  vector<int> na;
  na.push_back(0);
  for (int i = 0; i < a.size() - 1; i++) {
    na.push_back(a[i + 1] - a[i]);
  }
  for (int i = 0; i <= na.size(); i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = 2e9;
    }
  }
  dp[0][0] = 0;
  for (int i = 1; i < na.size(); i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = min(dp[i][j], dp[i - 1][j]);
      if (i - 1 && (long long)dp[i - 1][j - 1] + na[i] < 2e9)
        dp[i][j] = min(dp[i - 2][j - 1] + na[i], dp[i][j]);
      else if (j == 1)
        dp[i][j] = min(dp[i][j], na[1]);
    }
  }
  for (int i = 0; i < na.size(); i++) {
    for (int j = 0; j <= k; j++) {
      cout << dp[i][j] << " ";
    }
    cout << "\n";
  }
  cout << dp[na.size() - 1][k];
}
