#include <iostream>

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    long long n, k, last = 0;

    cin >> n >> k;

    long long niz[n];

    for(long long i = 0; i < n; ++i){
        cin >> niz[i];
    }
    for (long long i = 0; i < n - 1 && k != 0; ++i){
        if (niz[i] > niz[i + 1]){
            niz[i] = -1;
            --k;
        }
    }
    for(long long i = 0; i < n; ++i){
        if (niz[i] != -1) {
         cout << niz[i] << " ";
        }
    }
    return 0;
}