#include <bits/stdc++.h>
using namespace std;
vector<int> Arr;
int main() {
  int N, K;
  cin >> N >> K;
  int Num, Acum;
  int i, j;
  for (i = 0; i < N; i++) {
    cin >> Num;
    Arr.push_back(Num);
  }
  sort(Arr.begin(), Arr.end());
  j = 0;
  Acum = 0;
  for (i = 0; i < K; i++) {
    if (j >= Arr.size()) {
      cout << 0 << "\n";
      continue;
    }
    Arr[j] -= Acum;
    cout << Arr[j] << "\n";
    Acum += Arr[j];
    Arr[j] = 0;
    while (Arr[j] <= Acum && j < Arr.size()) j += 1;
  }
}
