#include <stdio.h>

using namespace std;

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

    int obrisani = 0;

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


    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);

        if(obrisani < k && a[i - 1] != -1 && a[i - 1] > a[i])
        {
            /*obrisani++;
            a[i - 1] = -1;

            ///DA LI JE SADA NEKO IZA VECI
            for(int j = i - 2; j >= 0; j--)
            {
                if(obrisani < k && a[j] != -1 && a[j] > a[i])
                {
                    obrisani++;
                    a[j] = -1;
                }
                else
                    break;
            }*/
            int start = i - 1;

            for(int j = i - 2; j >= 0; j--)
            {
                if(a[j] == a[j + 1])
                    start = j;
                else
                    break;
            }

            for(int j = start; j < i, obrisani < k; j++)
            {
                obrisani++;
                a[j] = -1;
            }
        }
    }

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

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

    return 0;
}