#include <iostream>
#include <string>
#include <vector>

int main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	std::string ulaz1;
	std::getline(std::cin, ulaz1);

	std::string ulaz2;
	std::getline(std::cin, ulaz2);

	int N = std::stoi(ulaz1.substr(0, ulaz1.find(" ")));
	int K = std::stoi(ulaz1.substr(ulaz1.find(" ")+1));

	std::vector<int> niz;

	for(int i = 0; i < N; ++i) {
		niz.push_back(std::stoi(ulaz2.substr(0, ulaz2.find(" "))));
		ulaz2 = ulaz2.substr(ulaz2.find(" ")+1);
	}

	for(int i = 0; i < N-1; ++i) {
		if(niz[i] > niz[i+1]) {
			if(K > 0) {
				niz.erase(niz.begin()+i);
				i--;
				K--;
				N--;
			}else{
				break;
			}
		}
	}

	for(auto& i : niz) {
		std::cout << i << ' ';
	}

	return 0;
}