#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long n, k, cur = 0;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (long long i = 0; i < min(n, k); i++) {
    if (a[i] - cur == 0) {
      k++;
      continue;
    }
    cout << a[i] - cur << "\n";
    cur += (a[i] - cur);
  }
  for (long long i = 0; i < k - n; i++) cout << 0 << "\n";
  return 0;
}
