#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m;
int a[N];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    int len = unique(a + 1, a + 1 + n) - (a + 1);
    int i = 1;
    int sum = 0;
    while (i <= len && m > 0) {
      printf("%d\n", a[i] - sum);
      sum += (a[i] - sum);
      i++;
      m--;
    }
    while (m > 0) printf("0\n"), m--;
  }
  return 0;
}
