#include <bits/stdc++.h>
using namespace std;
inline void normal(long long &a) { a = (a + 1000000007) % 1000000007; }
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInv(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInv(b));
}
void km() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a != 0) v.push_back(a);
  }
  sort((v).begin(), (v).end());
  long long a = 0;
  long long i = 0;
  long long j = 0;
  while (i < k) {
    if (j >= n) {
      cout << 0 << '\n';
      i++;
      continue;
    }
    if (v[j] - a == 0) {
      j++;
      continue;
    }
    cout << (v[j] - a) << '\n';
    a = v[j];
    j++;
    i++;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  clock_t start, end;
  start = clock();
  cout << fixed << setprecision(18);
  ;
  long long t;
  t = 1;
  while (t--) {
    km();
  }
  end = clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
}
