#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, j;
  cin >> n >> k;
  priority_queue<int, vector<int>, greater<int>> pq;
  for (int i = 0; i < n; i++) {
    cin >> j;
    pq.push(j);
  }
  int sum = 0;
  int x = pq.top();
  sum = x;
  cout << x << endl;
  x -= sum;
  pq.pop();
  k--;
  while (!pq.empty() && k > 0) {
    x = pq.top();
    pq.pop();
    int y = x;
    x -= sum;
    if (x == 0) continue;
    sum += x;
    cout << x << endl;
    k--;
  }
  if (k > 0 && pq.empty()) {
    while (k > 0) {
      cout << 0 << endl;
      k--;
    }
  }
  return 0;
}
