#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

struct Element { int index, val; };

bool cmp(Element a, Element b)
{
    return a.index < b.index;
}

int main()
{
    int n, k;
    int a[500000];

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

    scanf("%d%d", &n, &k);

    for(int i = 0; i < n; i++)
    {
        scanf("%d", &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)
        {
            if(a[i] != -1)
                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)
            printf("%d ", a[i]);
    }

    return 0;
}