#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[100010];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int tag = 0, now = 1;
  for (int i = 1; i <= k; i++) {
    while (now <= n && a[now] <= tag) now++;
    if (now > n)
      printf("0\n");
    else {
      int tmp = a[now] - tag;
      printf("%d\n", a[now] - tag);
      tag += tmp;
    }
  }
  return 0;
}
