#include <bits/stdc++.h>
using namespace std;
long long exp(long long base, long long power) {
  const int mod = 1e9 + 7;
  base = base % mod;
  long long result = 1;
  while (power > 0) {
    if (power & 1) {
      result = (result * base) % mod;
    }
    base = (base * base) % mod;
    power >>= 1;
  }
  return result;
}
void debug(int n, ...) {
  va_list v1;
  va_start(v1, n);
  for (int i = 0; i < n; i++) {
    int val = va_arg(v1, int);
    printf("%d ", val);
  }
  va_end(v1);
  printf("\n");
}
const int N = 2e5 + 7;
int a[N];
int cnt[N];
int av[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  priority_queue<pair<int, int>> pq;
  for (int i = 0; i < N - 2; i++) {
    if (cnt[i] > 0) pq.push({cnt[i], i});
  }
  for (int i = 0; i < N - 2; i++) av[i] = 1;
  vector<int> ans;
  while (ans.size() < k) {
    pair<int, int> topp = pq.top();
    ans.push_back(topp.second);
    pq.pop();
    av[topp.second]++;
    topp.first = cnt[topp.second] / av[topp.second];
    pq.push(topp);
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
}
