#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long count = 1;
  sort(a, a + n);
  cout << a[0] << '\n';
  long long flag = 0;
  for (long long i = 1; i < n; i++) {
    if (count == k) {
      flag = 1;
      break;
    } else {
      if (a[i] - a[i - 1] != 0) {
        cout << a[i] - a[i - 1] << '\n';
        count++;
      }
    }
  }
  if (flag == 0) {
    for (long long i = count + 1; i <= k; i++) {
      cout << 0 << '\n';
    }
  }
  return 0;
}
