#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, k, m;
int a[maxn], hsh[maxn], t[maxn];
struct Num {
  int id, w;
  bool operator<(const Num b) const { return w < b.w; }
};
struct Heap {
  Num a[maxn];
  int len;
  Heap() {
    memset(a, 0, sizeof a);
    len = 0;
  }
  void push(Num x) {
    a[++len] = x;
    int son = len;
    while (son > 1) {
      if (a[son / 2] < a[son])
        swap(a[son], a[son / 2]);
      else
        break;
      son >>= 1;
    }
  }
  Num get() {
    Num now = a[1];
    a[1] = a[len--];
    int fa = 1, son;
    while (fa * 2 <= len) {
      if (a[fa * 2 + 1] < a[fa * 2] || fa * 2 + 1 > len)
        son = fa * 2;
      else
        son = fa * 2 + 1;
      if (a[fa] < a[son])
        swap(a[son], a[fa]);
      else
        break;
      fa = son;
    }
    return now;
  }
} hep;
inline int read() {
  int ret = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= 48 && ch <= 57) {
    ret = ret * 10 + ch - 48;
    ch = getchar();
  }
  return ret * f;
}
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= n; i++) a[i] = read(), m = max(m, a[i]), hsh[a[i]]++;
  for (int i = 1; i <= m; i++) {
    if (!hsh[i]) continue;
    t[i]++;
    hep.push((Num){i, hsh[i]});
  }
  for (int i = 1; i <= k; i++) {
    Num now = hep.get();
    printf("%d ", now.id);
    t[now.id]++;
    hep.push((Num){now.id, hsh[now.id] / t[now.id]});
  }
  return 0;
}
