#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;
typedef vector<pi> vp;
typedef vector<bool> vb;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);

    int n, k;
    cin >> n >> k;

    vi a(n);
    for (auto& i : a)
        cin >> i;

    vb b(n, 0);
    int cnt = 0;
    for (int i = 0; i < n - 1; ++i){
        if (cnt == k) break;
        if (a[i] > a[i + 1]){
            b[i] = 1;
            ++cnt;
        }
    }

    int i = n - 1;
    while (cnt < k){
        if (b[i]) { i--; continue;}

        b[i] = 1;
        i--;
        ++cnt;
    }

    for (int i = 0; i < n; ++i)
        if (!b[i]) cout << a[i] << ' ';
    cout << '\n';
}