#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  map<long long, long long> f, d;
  multimap<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    ++f[a];
    d[a] = 1;
  }
  for (auto it : f) {
    m.insert({it.second, it.first});
  }
  for (long long i = 0; i < k; i++) {
    auto it = m.rbegin();
    cout << it->second << " ";
    d[it->second]++;
    m.insert({f[it->second] / d[it->second], it->second});
    m.erase(prev(m.end()));
  }
}
