#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int m = 0, l = 0;
  sort(a, a + n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] - s > 0) {
      cout << a[i] - s << endl;
      k--;
      s = a[i];
    }
    if (k == 0) break;
  }
  for (int i = 0; i < k; i++) cout << 0 << endl;
  return 0;
}
