#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  long long sum = 0;
  sort(a.begin(), a.end());
  int mini = 0;
  for (mini = 0; mini < n; mini++)
    if (a[mini] != 0) break;
  if (mini != n) {
    int z = 0;
    for (int i = mini; i < n && z < k; i++) {
      if (a[i] < sum) {
        for (int j = 0; j < k - z; j++) cout << 0 << '\n';
        cout << z << ' ' << k;
        exit(0);
      } else {
        if (a[i] - sum != 0) {
          cout << a[i] - sum << '\n';
          z++;
          sum += a[i] - sum;
          a[i] = 0;
        }
      }
    }
    for (int j = 0; j < k - z; j++) cout << 0 << '\n';
    exit(0);
  } else {
    for (int i = 0; i < k; i++) cout << 0 << '\n';
  }
}
