#include <bits/stdc++.h>
const double eps = 1e-8;
const double PI = acos(-1.0);
const long long llINF = 0x3f3f3f3f3f3f3f3f;
const long long INF = 0x3f3f3f3f;
using namespace std;
int main() {
  priority_queue<int, vector<int>, greater<int> > Q;
  int n, q;
  cin >> n >> q;
  for (int i = 1, tmp; i <= n; i++) {
    cin >> tmp;
    Q.push(tmp);
  }
  int allminus = 0, last = -1;
  for (int i = 1; i <= q; i++) {
    int tmp = 0;
    while (!Q.empty()) {
      tmp = Q.top();
      Q.pop();
      if (tmp != last) break;
    }
    cout << max(0, tmp - allminus) << endl;
    last = tmp;
    allminus += max(0, tmp - allminus);
  }
}
