#include <bits/stdc++.h>
using namespace std;
int x, n, m, k, j, a[100001];
long long sum;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  sum += a[0];
  if (a[0] > 0) cout << a[0] << endl;
  int i = 1;
  for (j = 1; j < k; j++) {
    if (sum < a[i]) {
      cout << a[i] - sum << endl;
      sum += a[i] - sum;
      i++;
    } else {
      if (i == n) break;
      i++;
      j--;
    }
  }
  for (j; j < k; j++)
    if (a[n - 1] - sum <= 0) cout << 0 << endl;
  return 0;
}
