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