#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, arr[200009], k;
  cin >> n >> k;
  for (long i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  long i = 0;
  long long diff = 0;
  long minel = -1;
  while (k > 0) {
    while (arr[i] == diff) i++;
    arr[i] = arr[i] - diff;
    minel = arr[i];
    diff = diff + minel;
    if (i >= n) {
      cout << "0\n";
    } else {
      cout << minel << "\n";
      i++;
    }
    k--;
  }
}
