#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 555;
int n, k;
int a[N];
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int id = 0;
  for (int i = 1; i <= n; ++i) {
    if (k <= 0) {
      return 0;
    }
    if (a[i] > id) {
      cout << a[i] - id << endl;
      id += (a[i] - id);
      k--;
    }
    if (k <= 0) {
      return 0;
    }
  }
  for (int i = 1; i <= k; ++i) {
    cout << 0 << endl;
  }
  return 0;
}
