#include <bits/stdc++.h>
using namespace std;
const long double Pi = 3.141592653;
const unsigned long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long sum = 0;
    int j = k;
    for (int i = 0; i < n; i++) {
      if (a[i] - sum > 0) {
        cout << a[i] - sum << "\n";
        a[i] = a[i] - sum;
        sum += a[i];
        j--;
      }
      if (j == 0) break;
    }
    while (j--) {
      cout << 0 << "\n";
    }
    cout << "\n";
  }
  return 0;
}
