#include <bits/stdc++.h>
using namespace std;
long long a[2 * 100005];
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long re = 0;
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    if (re == k) {
      return 0;
    }
    if (sum >= a[i])
      continue;
    else {
      cout << a[i] - sum << endl;
      sum += a[i] - sum;
      re++;
    }
  }
  if (k > re) {
    while (k > re) {
      cout << 0 << endl;
      re++;
    }
  }
}
