#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
  int n, k, s = 0, mx;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  mx = a[n - 1];
  for (int i = 0, j = 0; i < k; i++) {
    a[j] = a[j] > s ? a[j] - s : 0;
    while (j < n && !a[j]) {
      j++;
      a[j] = a[j] > s ? a[j] - s : 0;
    }
    cout << a[j] << endl;
    s = s + a[j] < mx ? s + a[j] : mx;
  }
  return 0;
}
