#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long N, M, sum = 0;
  scanf("%lld %lld", &N, &M);
  vector<long long> A(N);
  for (auto &a : A) scanf("%lld", &a);
  sort(A.begin(), A.end());
  long long cont = M;
  for (auto a : A) {
    if ((a - sum) == 0) continue;
    cont--;
    printf("%lld\n", a - sum);
    sum = sum + (a - sum);
    if (cont == 0) break;
  }
  while (cont--) {
    puts("0");
  }
}
