#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i, j, temp, count = 0;
  cin >> n >> k;
  long long arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  cout << arr[0] << endl;
  count = 1;
  i = 1;
  j = arr[0];
  temp = k;
  while (--temp && i < n) {
    if (arr[i] - j != 0) {
      cout << arr[i] - j << endl;
      count++;
      j += arr[i] - j;
      i++;
    } else if (arr[i] - j == 0) {
      j += arr[i] - j;
      i++;
      ++temp;
    }
  }
  while (count < k) {
    cout << "0" << endl;
    count++;
  }
  return 0;
}
