#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n + 1, 0);
  for (long long int i = 1; i <= n; ++i) cin >> a[i];
  sort(next(a.begin()), a.end(),
       [](const long long int &x, const long long int &y) {
         if (x == 0 || y == 0) return true;
         return x < y;
       });
  a.erase(unique(next(a.begin()), a.end()), a.end());
  long long int sub = 0;
  for (long long int i = 1; i <= k; ++i) {
    if (i > n)
      cout << 0 << endl;
    else {
      cout << max(0LL, a[i] - sub) << endl;
      if (a[i] - sub > 0) sub += a[i] - sub;
    }
  }
  return 0;
}
