#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 10;
int read() {
  int xx = 0, ww = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') ww = -ww;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    xx = 10 * xx + ch - 48;
    ch = getchar();
  }
  return xx * ww;
}
int n;
int a[100010];
priority_queue<int, vector<int>, greater<int> > q;
int last = 0, k;
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    q.push(a[i]);
  }
  for (int i = 1; i <= k; i++) {
    if (q.empty()) {
      puts("0");
      continue;
    }
    while (!q.empty() && q.top() - last <= 0) q.pop();
    if (q.empty()) {
      puts("0");
      continue;
    }
    int x = q.top();
    x -= last;
    last += x;
    printf("%d\n", x);
    q.pop();
  }
  return 0;
}
