#include <bits/stdc++.h>
long long base = 0;
std::priority_queue<long long, std::vector<long long>, std::greater<long long>>
    que;
int main() {
  long long n, k;
  std::cin >> n >> k;
  for (int i = 1, buf; i <= n; i++) std::cin >> buf, que.push(buf);
  while (k--) {
    while (!que.empty() && que.top() == base) que.pop();
    if (que.empty())
      puts("0");
    else {
      printf("%lld\n", que.top() - base);
      base += que.top() - base;
      que.pop();
    }
  }
  return 0;
}
