#include <bits/stdc++.h>
int dx[] = {0, 0, 1, 1};
int dy[] = {1, 1, 0, 0};
using namespace std;
vector<long long int> v, v2, v3;
vector<int>::iterator it1, it2;
vector<pair<long long int, long long int> > vp;
priority_queue<pair<long long int, long long int> > pq;
long long int arr[2000100], arr2[2000100];
int main() {
  long long int n, k, ans = 0, cnt = 0, a, k1;
  scanf("%lld %lld", &n, &k);
  k1 = k;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a);
    arr[a]++;
    arr2[a] = 1;
    if (a > cnt) cnt = a;
  }
  for (int i = 1; i <= cnt; i++) {
    if (arr[i] > 0) pq.push({arr[i], i});
  }
  while (k--) {
    pair<long long int, long long int> tmp = pq.top();
    pq.pop();
    v2.push_back(tmp.second);
    arr2[tmp.second]++;
    tmp.first = arr[tmp.second] / arr2[tmp.second];
    pq.push(tmp);
  }
  for (int i = 0; i < k1; i++) {
    printf("%lld ", v2[i]);
  }
  printf("\n");
  return 0;
}
