#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long arr[maxn];
int n, k;
int main(void) {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%I64d", &arr[i]);
  sort(arr + 1, arr + 1 + n);
  long long sub = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] > sub) {
      printf("%I64d\n", (arr[i] - sub));
      sub += (arr[i] - sub);
      if (--k == 0) break;
    }
  }
  while (k) {
    puts("0");
    k--;
  }
  return 0;
}
