#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);
    cin.tie(0);
    cout.tie();
  }
  {}
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long sum = 0;
  sort(a, a + n);
  int i = 0;
  do {
    if (k == 0) break;
    while (a[i] - sum <= 0 && i < n) i++;
    if (i >= n)
      cout << 0;
    else {
      cout << a[i] - sum;
      sum += a[i] - sum;
    }
    cout << "\n";
    k--;
  } while (1);
  return 0;
}
