#include using namespace std; #define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++) #define rrep(i, r, l) for (int i = (int)(r); i > (int)(l); i--) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() void solve() { int n, k; cin >> n >> k; --k; vector a(n); rep(i, 0, n) cin >> a[i]; vector ans(n, -1); int l = 0, r = n - 1, now = 0; rep(i, 0, n - 1) { if (a[i] < a[i + 1]) { rrep(j, now, -1) { ans[r] = i - j; --r; } now = 0; } else if (a[i] > a[i + 1]) { rrep(j, now, -1) { ans[l] = i - j; ++l; } now = 0; } else { now++; } } if (ans[k] == -1) { ans[k] = n - 1; } rep(i, 0, n) { if (i == ans[k]) { continue; } cout << a[i] << ' '; } cout << '\n'; } int main() { int t = 1; // cin >> t; while (t--) { solve(); } }