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