#include <cstdio>
#include <cstring>
#include <algorithm>

#include <set>
#include <vector>

using namespace std;

struct broj {
	int val, n;	
	broj() {}
	broj( int _val ) { val = _val; n = 1; }
	broj( int _val, int _n ) { val = _val; n = _n; }
};

struct cmp {
	bool operator()( const broj A, const broj B ) {
		return A.val > B.val;	
	}	
};

int N, K;
int niz[ 1001 ], poz[ 1001 ];
set< broj, cmp > S;
set< broj, cmp >::iterator it;
vector< broj > V;

bool operator < ( const broj &A, const broj &B ) {
	if( A.n == B.n ) return poz[ A.val ] < poz[ B.val ];
	return A.n > B.n;	
}

int main( void ) {
	memset( poz, -1, sizeof poz );
	
	scanf( "%d %d", &N, &K );
	for( int i = 0; i < N; ++ i ) {
		scanf( "%d", niz + i );
		if( poz[ niz[ i ] ] == -1 ) poz[ niz[ i ] ] = i;
		it = S.find( broj( niz[ i ] ) );
		if( it != S.end() ) {
			broj tmp = broj( it -> val, ( it -> n ) + 1 );
			S.erase( it );
			S.insert( tmp );
		} else
			S.insert( broj( niz[ i ] ) );
	}
	for( it = S.begin(); it != S.end(); ++ it ) {
		broj tmp = broj( it -> val, it -> n );
		V.push_back( tmp );
	}
	
	sort( V.begin(), V.end() );
	
	for( int i = 0; i < V.size(); ++ i )
		for( int j = 0; j < V[ i ].n; ++ j )
			printf( "%d ", V[ i ].val );
	printf( "\n" );
	return 0;	
}
