#include using namespace std; int main(){ int N, K; cin >> N >> K; K--; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector> P; P.push_back(make_pair(A[0], 1)); for (int i = 1; i < N; i++){ if (A[i] == A[i - 1]){ P.back().second++; } else { P.push_back(make_pair(A[i], 1)); } } int cnt = P.size(); deque dq; for (int i = 0; i < P[cnt - 1].second; i++){ dq.push_back(cnt - 1); } for (int i = cnt - 2; i >= 0; i--){ if (P[i].first < P[i + 1].first){ for (int j = 0; j < P[i].second; j++){ dq.push_back(i); } } else { for (int j = 0; j < P[i].second; j++){ dq.push_front(i); } } } int p = dq[K]; int s = 0; for (int i = 0; i < p; i++){ s += P[i].second; } A.erase(A.begin() + s); for (int i = 0; i < N - 1; i++){ cout << A[i]; if (i < N - 2){ cout << ' '; } } cout << endl; }