#include <bits/stdc++.h>
using namespace std;
long long arr[200002];
vector<long long> v[100002];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long i;
  priority_queue<long long, vector<long long>, greater<long long> > pq;
  for (i = 0; i < n; i++) {
    long long x;
    cin >> x;
    pq.push(x);
  }
  long long diff = 0;
  while (k--) {
    while (!pq.empty() and (pq.top() - diff) == 0) pq.pop();
    if (pq.empty())
      cout << 0 << '\n';
    else
      cout << pq.top() - diff << '\n';
    diff += (pq.top() - diff);
  }
  return 0;
}
