#include<iostream>
#include<queue>
#include<stack>
using namespace std;
int main()
{
int v,k;
while(cin>>v>>k)
{
priority_queue<int>big_head;
while(v--)
{
int data;
cin>>data;
if(big_head.size()<k)
{
big_head.push(data);
}
else
{
if(big_head.top()>data)
{
big_head.pop();
big_head.push(data);
}
}
}
stack<int>s;
while(!big_head.empty())
{
s.push(big_head.top());
big_head.pop();
}
while(!s.empty())
{
if(s.size()>1){
cout<<s.top()<<" ";
}
else{
cout<<s.top()<<endl;
}
s.pop();
}
}
return 0;
}