#include <bits/stdc++.h>
#define MAXN 500005
using namespace std;

set<int> s[MAXN];
int a[MAXN],conv[MAXN];
pair<int,int> p[MAXN];
vector<int> v;
vector<int> sol;
vector<int> res;

int main()
{ int n,k,i;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
{
    scanf("%d",&a[i]);

    p[i].first=a[i]; p[i].second=i;
}

sort(p,p+n);

int cnt=1;

a[ p[0].second ]=1;
v.push_back(1);

for(i=1;i<n;i++)
{
    if(p[i-1].first!=p[i].first)
    {
        cnt++;
        v.push_back(cnt);
    }

    a[ p[i].second ]=cnt;
}

for(i=0;i<n;i++)
{
    conv[ a[ p[i].second ] ]=p[i].first;

    p[i].first=a[ p[i].second ];
}

for(i=0;i<n;i++)
{
    s[ p[i].first ].insert(p[i].second);
}

int now=0;

for(i=0;i<v.size();i++)
{
    int t=v[i];

    set<int>::iterator it;

    for(it=s[t].begin();it!=s[t].end();*it++)
    {
        int x=*it; int tmp=x-now;

        //cout << now << " " << x << " " << k << endl;

        if(tmp<=k && tmp>=0)
        {
            //for(int j=now;j<=x;j++) cout << a[j] << " ";

            sol.push_back(x);

            //cout << now << " " << x << endl;

            now=x+1;

            k-=tmp;

            //cout << k << endl;
        }

        if(k<=0) break;
    }

    if(k<=0) break;
}

k=max(0,k);

for(i=0;i<sol.size();i++) res.push_back(conv[a[sol[i]]]);
for(i=now;i<n;i++) res.push_back(conv[ a[i] ]);

for(i=0;i<res.size()-k;i++) printf("%d ",res[i]);
    return 0;
}