#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Element { int index, val; };

bool cmp(Element a, Element b)
{
    return a.val > b.val;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    int a[500000];

    Element pret = { -1, -1 };
    vector<Element> obrisani;

    cin >> n >> k;

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];

        if(pret.val != -1)
        {
            if(pret.val > a[i])
            {
                obrisani.push_back({pret.index, pret.val});
            }
        }

        pret = { i, a[i] };
    }

    if(obrisani.size() < k)
    {
        int i = n - 1;
        while(obrisani.size() != k)
        {
            obrisani.push_back({ i++, a[i] });
        }
    }

    sort(obrisani.begin(), obrisani.end(), cmp);

    for(int i = 0; i < k; i++)
    {
        a[obrisani[i].index] = -1;
    }

    for(int i = 0; i < n; i++)
    {
        if(a[i] != -1)
            cout << a[i] << " ";
    }

    return 0;
}