#include <bits/stdc++.h>
using namespace std;
void Fastio() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long fact[1000006], inv[1000006];
long long fp(long long base, long long exp) {
  if (exp == 0) return 1;
  long long ans = fp(base, exp / 2);
  ans = (ans * ans) % 100000000000000000;
  if (exp % 2 != 0)
    ans = (ans * (base % 100000000000000000)) % 100000000000000000;
  return ans;
}
void calcFacAndInv(long long n) {
  fact[0] = inv[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (i * fact[i - 1]);
    inv[i] = fp(fact[i], 100000000000000000 - 2);
  }
}
long long ncr(long long n, long long r) {
  return ((fact[n] * inv[r]) % 100000000000000000 * inv[n - r]) %
         100000000000000000;
}
long long npr(long long n, long long r) {
  return (fact[n] * inv[n - r]) % 100000000000000000;
}
long double NCR(int n, int m) {
  long double res = 1;
  m = min(m, n - m);
  for (int i = 0; i < m; i++) {
    res = res * (n - i) / (i + 1);
  }
  return res;
}
int main() {
  Fastio();
  int n, k;
  cin >> n >> k;
  map<int, double> mp;
  set<int> s;
  priority_queue<pair<double, pair<int, int> > > q;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[x]++;
    s.insert(x);
  }
  while (!s.empty()) {
    q.push({mp[*s.begin()], {*s.begin(), 1}});
    s.erase(s.begin());
  }
  while (k) {
    int cur = q.top().second.first, t = q.top().second.second + 1;
    double r = q.top().first;
    q.pop();
    cout << cur << " ";
    q.push({mp[cur] / t, {cur, t}});
    k--;
  }
  return 0;
}
