#include <bits/stdc++.h>
using namespace std;
double max(double a, double b) {
  if (a > b) return a;
  return b;
}
double min(double a, double b) {
  if (a > b) return b;
  return a;
}
int removeDuplicates(int arr[], int n) {
  if (n == 0 || n == 1) return n;
  int j = 0;
  for (int i = 0; i < n - 1; i++)
    if (arr[i] != arr[i + 1]) arr[j++] = arr[i];
  arr[j++] = arr[n - 1];
  return j;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  n = removeDuplicates(arr, n);
  int sub;
  for (int i = 0; i < k; i++) {
    if (i >= n) {
      cout << "0" << '\n';
      continue;
    }
    if (i == 0) {
      sub = arr[i];
      cout << arr[i] << '\n';
    } else {
      cout << arr[i] - sub << '\n';
      sub += arr[i] - sub;
    }
  }
  return 0;
}
