#include <bits/stdc++.h>
using namespace std;
template <class T>
using VV = vector<vector<T>>;
template <class T>
inline T SMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}
template <class T>
inline T SMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class Iter>
void dumpc(Iter begin, Iter end) {
  if (true) {
    for (; begin != end; ++begin) {
      cerr << *begin << ',';
    }
    cerr << endl;
  }
}
const int MAX_N = 1e6 + 1;
long long A[MAX_N];
int N, K;
void solve() {
  sort(A, A + N);
  int i = 0;
  long long sum = 0;
  while (K--) {
    int res = i >= N ? 0 : A[i] - sum;
    fprintf(stdout, "%d", res), putchar('\n');
    ;
    sum += res;
    while (i < N && A[i] <= sum) ++i;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(12) << fixed;
  cin >> N >> K;
  for (int i = 0; i < (N); ++i) cin >> A[i];
  solve();
  return 0;
}
