#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

struct brojevi {
  int vr;
  int pojav;
  int prvo;
};
/*
struct cmp {
  inline bool operator () (
*/

bool cmp (const brojevi &a, const brojevi &b)  {
  if (a.pojav>b.pojav) return true;
  else if (a.pojav==b.pojav) {
    if (a.prvo<b.prvo) return true;
    else return false;
  }
  else return false;
}
  

int main(void) {
  
  int n, c;
  map<int, int>niz;
  map<int, int>pomoc;
  map<int,int>::iterator it;
  scanf("%d%d", &n, &c);
  int niz2[n];
  vector<brojevi>niz3(n);
  for (int i=0; i<n; i++) {
    scanf("%d", &niz2[i]);
      niz[niz2[i]]=0;
      /////////
      pomoc[niz2[i]]=-1;
  }
  for (int i=0; i<n; i++) {
     niz[niz2[i]]++;
     if (pomoc[niz2[i]] == -1) {
        pomoc[niz2[i]]=i;
      }
    }
    int i=0;
      for ( it=niz.begin() ; it != niz.end(); it++ ) {
    int a=(*it).first;
    int b=(*it).second;
    niz3[i].vr=a;
    niz3[i].pojav=b;
    i++;
  }
  /////////////////////////////////
  i=0;
  for ( it=pomoc.begin() ; it != pomoc.end(); it++ ) {
    int b=(*it).second;
    niz3[i].prvo=b;
    i++;
  }
  sort(niz3.begin(), niz3.end(), cmp);
  for (int i=0; i<n; i++) {
    for (int j=0; j<niz3[i].pojav; j++) {
    printf("%d ", niz3[i].vr);
  }
  }
  printf("\n");
 // system("pause");
  return (7-7);
}
