#include <bits/stdc++.h>
using namespace std;
int n, k;
long a[100005];
void Input() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%ld", &a[i]);
}
void Solve() {
  sort(a + 1, a + n + 1);
  int index = 1;
  long substract = 0;
  for (int i = 1; i <= k; i++) {
    while (a[index] == 0 && index <= n) index++;
    if (index > n) {
      cout << 0 << endl;
      continue;
    }
    long tmp = a[index];
    if (i != 1) a[index] -= substract;
    cout << a[index] << endl;
    substract += a[index];
    a[index] = 0;
    index++;
    while (a[index] == tmp && index <= n) {
      a[index] = 0;
      index++;
    }
  }
}
int main() {
  Input();
  Solve();
  return 0;
}
