#include <iostream>;
#include <iomanip>;
#include <vector>;
#include <map>;
#include <stack>;
#include <cstdio>
#include <cstring>;
#include <algorithm>;
using namespace std;
int n,k,a[500005];
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=2;i<=n and k>0;i++){
        if(a[i]<a[i-1] and a[i-1]!=-1){
                a[i-1]=-1;
                k--;
                i--;
        //cout<<3;
        }
        //cout<<1;
    }
    for(int i=2;i<=n and k>0;i++){
        if(a[i]<a[i-1] and a[i-1]!=-1){
                a[i-1]=-1;
                k--;
                i--;
        //cout<<3;
        }
        //cout<<1;
    }
    for(int i=1;i<=n;i++){
        if(a[i]!=-1)cout<<a[i]<<" ";
    }
return 0;
}