#include <stdlib.h>
#include <stdio.h>

int main()
{
    long N, K, i, p, min, minp, mind, mindp;
    long A[500];
    long M[500];

    scanf("%li%li", &N, &K);

    for(i=0; i<N; i++)
    {
        scanf("%li", &A[i]);
        M[i] = 1;
    }

    p = -1;
    while(K>0 && p<N-K-1)
    {
        min = A[p+1];
        minp = p + 1;
        mind = A[p+2];
        mindp = p +2;
        for(i=p+2; i<=p+K+1; i++)
            if(A[i]<min)
            {
                min = A[i];
                minp = i;
                mind = A[i+1];
                mindp = i +1;
            }
            else
                if(A[i]<mind)
                {
                    mind = A[i];
                    mindp = i;
                }

        for(i=p+1; i<minp; i++)
            M[i] = 0;




        if(mind<A[p+K+2])
        {
            for(i=minp+1; i<mindp; i++)
                M[i] = 0;
            K = K - (mindp - p - 1);
            p = mindp;
        }
        else
            {
                for(i=minp+1; i<p+K+2; i++)
                    M[i] = 0;
                K = 0;
                p = p + K + 2;
            }

    }


    for(i=N-K; i<N; i++)
        M[i] = 0;

    for(i = 0; i<N; i++)
        if(M[i]==1)
            printf("%li ", A[i]);


    system("PAUSE");
    return 0;
}