#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1000000001, INF = (ll)1e18 + 1;
const int maxn = 2e5 + 10;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  vector<int> cnt(maxn + 1, 0);
  for (int i = 0; i < n; i++) cnt[s[i]]++;
  priority_queue<pair<int, int> > q;
  for (int i = 0; i <= maxn; i++) {
    if (cnt[i]) q.push({cnt[i], i});
  }
  vector<int> ans, qnt(maxn + 1, 0);
  while (k--) {
    int i = q.top().second;
    q.pop();
    qnt[i]++;
    ans.push_back(i);
    if (cnt[i] / (qnt[i] + 1) != 0) q.push({cnt[i] / (qnt[i] + 1), i});
  }
  for (int i : ans) cout << i << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
