#include <bits/stdc++.h>
using namespace std;
int n, k, x, freq[200005], ans_freq[200005];
int main() {
  ios_base::sync_with_stdio(0);
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    freq[x]++;
  }
  priority_queue<pair<int, int>> pq;
  for (int i = 1; i < 200005; i++) {
    if (freq[i]) {
      pq.push({freq[i], i});
    }
  }
  for (int i = 1; i <= k; i++) {
    x = pq.top().second;
    pq.pop();
    printf("%d ", x);
    pq.push({freq[x] / (++ans_freq[x] + 1), x});
  }
  return 0;
}
