#include <iostream>
typedef unsigned long long llu;

using namespace std;

int main()
{
    llu n,k,i,j,m,ind=0;
    cin>>n>>k;
    llu A[n];
    for (i=0; i<n; ++i)
        cin>>A[i];
    for (j=1; j<=k; ++j)
    {
        ind=0;
        for (i=0; i<n-1; ++i)
        {
            if (A[i]>A[i+1] && A[i+1]!=-1)
            {
                A[i]=-1;
                ind=1;
                break;
            }
        }
        if (ind==1) break;
        for (m=0; m<n; ++m)
            {
                if (A[m]!=-1)
                    A[m]=-1;
                    break;
            }
    }
    for (i=0; i<n; ++i)
    {
        if (A[i]!=-1)
            cout<<A[i]<<" ";
    }
    return 0;
}