#include <bits/stdc++.h>
using namespace std;
const int NMAX=5e5+7;
const int INF=1e9+7;

int n,k,a[NMAX],brisi[NMAX];

struct segTree
{
    int t[4*NMAX];
    void update(int node, int st, int en, int idx, int val)
    {
        if(st==en)
        {
            t[node]=val;
            return;
        }
        int mid=(st+en)/2;
        if(idx<=mid) update(2*node, st, mid, idx, val);
        else update(2*node+1, mid+1, en, idx, val);
        t[node]=min(t[2*node], t[2*node+1]);
    }
    int get(int node, int st, int en, int l, int r)
    {
        if(st>en || st>r || en<l) return INF;
        if(l<=st && en<=r) return t[node];
        int mid=(st+en)/2;
        int t1=get(2*node, st, mid, l, r);
        int t2=get(2*node+1, mid+1, en, l, r);
        return min(t1,t2);
    }
}T;

int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    //for(int i=n+1;i<=n+k;i++) a[i]=INF;
    for(int i=1;i<=n;i++) T.update(1, 1, n, i, a[i]);
    for(int i=1;i<=n;i++)
    {
        if(T.get(1, 1, n, i+1, i+k)<a[i]) brisi[i]=1, k--; 
        if(k==0) break;
    }
    int i=n;
    while(k)
    {
        if(!brisi[i]){brisi[i]=1;k--;}
        i--;
    }
    for(int i=1;i<=n;i++) if(!brisi[i]) cout<<a[i]<<" ";
    return 0;
}