#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } k--; deque Q; Q.push_back(n - 1); for (int i = n - 2; i >= 0; i--) { if (a[i] == a[i + 1]) { if (Q.back() == i + 1) { Q.push_back(i); } else { Q.push_front(i); } } else if (a[i + 1] < a[i]) { Q.push_front(i); } else { Q.push_back(i); } } for (int i = 0; i < n; i++) { if (i == Q[k]) { continue; } cout << a[i] << ' '; } cout << endl; }