#include <bits/stdc++.h>
using namespace std;
long long int A[5000001];
vector<long long int> v;
vector<pair<long long int, long long int> > v2;
int main() {
  long long int n, k, sum = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> A[i];
  sort(A, A + n);
  for (int i = 0; i < n; i++) {
    if (k == 0) break;
    A[i] -= sum;
    if (A[i] <= 0 && i < n - 1) continue;
    sum += A[i];
    cout << A[i] << endl;
    k--;
  }
  while (k != 0) {
    cout << "0" << endl;
    k--;
  }
  return 0;
}
