#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x;
  cin >> n >> k;
  int arr[n];
  vector<int> v(k, 0);
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
  }
  sort(arr, arr + n);
  int idx = 0;
  long long ctn = 0;
  int id = 0;
  while (id < k && idx < n) {
    arr[idx] -= ctn;
    if (arr[idx] <= 0) {
      ++idx;
      continue;
    }
    v[id] = arr[idx];
    ctn += arr[idx];
    ++id;
    ++idx;
  }
  for (int i = 0; i < k; i++) {
    cout << v[i] << endl;
  }
}
