#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int i, a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  if (a[0] == a[n - 1] && a[0] == 0) {
    while (k--) cout << 0 << endl;
  }
  long long int b[n], ct = 0;
  for (i = 0; i < n; i++) {
    while (i < n && a[i] == a[i + 1]) i++;
    b[ct++] = a[i];
  }
  i = 0;
  long long int cnt = 0;
  while (k--) {
    while (b[i] == 0) i++;
    if (i >= ct)
      cout << 0 << endl;
    else
      cout << b[i] - cnt << endl;
    cnt = b[i];
    i++;
  }
}
