#include <bits/stdc++.h>
using namespace std;
long long const inf = 1e9;
long long const mod = 1e9 + 7;
long double const eps = 1e-9;
int main() {
  int n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = (0); i < (n); i++) cin >> a[i];
  sort(a, a + n);
  long long sum = 0;
  int j = 0;
  for (int i = (0); i < (k); i++) {
  begins:
    if (j >= n)
      cout << 0 << endl;
    else {
      if (a[j] - sum == 0) {
        j++;
        goto begins;
      }
      cout << a[j] - sum << endl;
      ;
      sum += (a[j] - sum);
      j++;
    }
  }
}
