#include <bits/stdc++.h>
int a[100005];
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  qsort(a, n, 4, cmp);
  int now = 0, j = 0;
  for (int i = 0; i < k; i++) {
    if (a[j] >= now)
      printf("%d\n", a[j] - now);
    else
      printf("0\n");
    now += a[j] - now;
    while (now >= a[j] && j < n) {
      j++;
    }
  }
  return 0;
}
