#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  long long n, k, sub = 0, i, f, j, st;
  cin >> n >> k;
  for (i = 0; i < n; i++) cin >> a[i];
  j = 0;
  sort(a, a + n);
  for (i = 0; i < k; i++) {
    if (j == n) cout << 0 << endl;
    for (; j < n; j++) {
      if (j == n - 1 && a[j] <= sub) cout << 0 << endl;
      if (a[j] > sub) {
        cout << a[j] - sub << endl;
        sub += (a[j] - sub);
        break;
      }
    }
  }
}
