#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;
priority_queue<int, vector<int>, greater<int>> pq;
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    pq.push(x);
  }
  int ft = 0;
  while (m--) {
    while (pq.size() != 0 && pq.top() <= ft) {
      pq.pop();
    }
    if (pq.size() == 0) {
      for (int i = m; i >= 0; i--) {
        printf("%d\n", 0);
      }
      break;
    }
    int t = pq.top();
    pq.pop();
    printf("%d\n", t - ft);
    ft = t;
  }
  return 0;
}
