#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    int arr[500000];
    for (int i = 0; i < n; ++i) cin >> arr[i];
    int prev = arr[0], prev_index=0;
    int next = arr[1];
    for (int i = 1; i < n; ++i)
    {
        if (k<=0) break;
        next = arr[i];
        if (prev>next) { --k; arr[prev_index] = -1; }
        prev = next;  prev_index = i;
    }
    int cnt=0;
    int nx;
    for (int i = 0; i < n; ++i)
        {
            if (arr[i]!=-1 and cnt==0)
                {
                    prev = arr[i]; prev_index = i; break;
                }
            else {next = arr[i]; nx = i; break;}
        }

    while(k>0)
    {
        if (nx>n-1) break;
        if (arr[nx]==-1) {++nx; continue; }
        next = arr[nx];
        if (prev>next) {--k;arr[prev_index] = -1;}
        prev = next;  prev_index = nx;
        ++nx;
    }
    for (int i = 0; i < n; ++i)
    {
        if (arr[i]!=-1) cout << arr[i] << " ";
    }
}