#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  priority_queue<int, vector<int>, greater<int> > q;
  for (int i = 1, a; i <= n; i++) {
    scanf("%d", &a);
    q.push(a);
  }
  int add = 0;
  while (k--) {
    while (!q.empty() && q.top() == add) q.pop();
    if (q.empty())
      puts("0");
    else {
      int top = q.top();
      q.pop();
      top -= add;
      add += top;
      cout << top << endl;
    }
  }
  return 0;
}
