#include <bits/stdc++.h>
using namespace std;
long long a = 1, b, c, sz, w, h, n, x, x2, y, y2, ans, cnt;
string m, k;
set<int> s;
vector<int> v, v1;
int main() {
  setlocale(LC_ALL, "rus");
  ;
  ;
  ios_base::sync_with_stdio(0);
  ;
  cin >> a >> x2;
  for (int i = 0; i < a; i++) {
    cin >> b;
    v.push_back(b);
    s.insert(b);
  }
  while (x2) {
    if (!s.empty()) {
      x = *s.begin();
      s.erase(x);
      x -= y;
      cout << x << endl;
      y += x;
    } else {
      cout << 0 << endl;
    }
    x2--;
  }
}
