#include using namespace std; // #include // #include // #include // using namespace __gnu_pbds; // #include // #include // namespace mp = boost::multiprecision; // #include // using namespace atcoder; // https://atcoder.github.io/ac-library/production/document_ja/ typedef long long int ll; typedef long double ld; const ll mod = 1e9+7; const ll INF = 922337203685477580; #define rep(i,n) for (ll i = 0; i < (n); ++i) #define Rep(i,a,n) for (ll i = (a); i < (n); ++i) #define All(a) (a).begin(),(a).end() #define Pi acos(-1) using V = vector; using P = pair; vector dx = {1, 0, -1, 0, 1, 1, -1, -1}; vector dy = {0, 1, 0, -1, 1, -1, 1, -1}; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b >; struct IoSetup { IoSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << setprecision(15) << fixed; } } iosetup; void printvec(vector a) { for(ll i = 0; i < a.size(); i++) { cout << a[i] << ' '; } cout << '\n'; } void printgrid(vector> g) { for (ll i = 0; i < g.size(); i++) { printvec(g[i]); } } int main() { ll n, k; cin >> n >> k; vector a(n); rep(i, n) cin >> a[i]; vector b(n); ll l = 1, r = n; ll cnt = 1; rep(i,n-1) { if (a[i] > a[i+1]) { rep(j, cnt) { b[i+j] = l; l++; cnt = 1; } } else if (a[i] < a[i+1]) { rep(j, cnt) { b[i+j] = r; r--; cnt = 1; } } else { cnt++; } } if (cnt != 1) { rep(j, cnt) { b[n-2-j] = r; r--; } } b[n-1] = l; rep(i,n) { if (b[i] != k) { cout << a[i] << ' '; } } cout << '\n'; }