// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



const int maxn=5e5+10;



void read(int &x)

{

	char c=getchar(); x=0;

	while (c<'0'||c>'9') c=getchar();

	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();

}



int n,k,p[maxn],q[maxn],deg[maxn];

int tote,FIR[maxn],TO[maxn<<1],NEXT[maxn<<1];

priority_queue<int> pq;



namespace SegTree{

	int mn[maxn<<2];

#define lc (nd<<1)

#define rc (nd<<1|1)

#define mid ((s+t)>>1)



	void init()

	{

		memset(mn,0x3f3f3f3f,sizeof(mn));

	}



	void update(int nd,int s,int t,int id,int val)

	{

		if (s==t) {mn[nd]=val; return;}

		if (id<=mid) update(lc,s,mid,id,val);

		else update(rc,mid+1,t,id,val);

		mn[nd]=min(mn[lc],mn[rc]);

	}



	int query(int nd,int s,int t,int l,int r)

	{

		if (l<=s&&t<=r) return mn[nd];

		int Ans=0x7fffffff;

		if (l<=mid) Ans=min(Ans,query(lc,s,mid,l,r));

		if (r> mid) Ans=min(Ans,query(rc,mid+1,t,l,r));

		return Ans;

	}

}



void addedge(int u,int v)

{

	TO[++tote]=v;

	NEXT[tote]=FIR[u];

	FIR[u]=tote;

	deg[v]++;

}



int main()

{

	int i,x;

	read(n); read(k);

	for (i=1;i<=n;i++)

		read(p[i]),q[p[i]]=i;

	SegTree::init();

	for (i=n;i>=1;i--)

	{

		x=SegTree::query(1,1,n,q[i]-k+1,q[i]);

		if (x<=n) addedge(q[x],q[i]);

		x=SegTree::query(1,1,n,q[i],q[i]+k-1);

		if (x<=n) addedge(q[x],q[i]);

		SegTree::update(1,1,n,q[i],i);

	}

	for (i=1;i<=n;i++)

		if (!deg[i]) pq.push(i);

	for (i=n;i>=1;i--)

	{

		int u=p[i]=pq.top(); pq.pop();

		for (int p=FIR[u];p;p=NEXT[p])

			if (!(--deg[TO[p]])) pq.push(TO[p]);

	}

	for (i=1;i<=n;i++) q[p[i]]=i;

	for (i=1;i<=n;i++) printf("%d\n",q[i]);

}


// Faster C++ solution for the same problem (measured speedup: 9.381622604231918x):
#include<bits/stdc++.h>



using namespace std ;



#define inf 99999999

#define N 1000007

#define ls x<<1

#define rs x<<1|1



priority_queue< int , vector<int> , greater<int> > q ;



int tot , n , m , cnt , k ;

int nex[2*N] , fire[N] , to[2*N] ;

int To[N] , Mn[4*N] , in[N] , Ans[N] ;



inline int read()

{

    int x = 0 , f = 1 ; char c = getchar();

    while( c < '0' || c > '9' ) { if( c == '-' ) f = -1; c = getchar() ; }

    while( c >= '0' && c <= '9' ) x = x * 10 + c - 48 , c = getchar() ;

    return x * f ;

}



void add(int u , int v){

    nex[++tot] = fire[u] ;

    fire[u] = tot ;

    to[tot] = v ;

    in[v]++ ;

    return ;

}



void build(int x , int l , int r){

    Mn[x] = inf ;

    if( l == r ) return ;

    int mid = l + r >> 1 ;

    build( ls , l , mid ) ; build( rs , mid + 1 , r ) ;

}



void update(int x , int l , int r , int pos , int t ){

    Mn[x] = min( Mn[x] , t ) ;

    if( l == r ) return ;

    int mid = l + r >> 1 ;

    if( pos <= mid ) update( ls , l , mid , pos , t ) ;

    else update( rs , mid + 1 , r , pos , t ) ;

}



int Ask(int x , int l , int r , int ll , int rr){

    if( ll > rr ) return inf ;

    if( l > rr || r < ll ) return inf ;

    if( ll <= l && r <= rr ) return Mn[x] ;

    int mid = l + r >> 1 ;

    return min( Ask( ls , l , mid , ll , rr ) , Ask( rs , mid + 1 , r , ll , rr ) ) ;

}



void topo(){

    for(int i = 1 ; i <= n ; i++ ) if( !in[i] ) q.push( i ) ;

    while( !q.empty() ){

        int u = q.top() ; q.pop() ;

        Ans[u] = ++cnt ;

        for(int i = fire[u] ; i ; i = nex[i] ){

            int v = to[i] ;

            in[v]-- ;

            if( !in[v] ) q.push( v ) ;

        }

    }

    return ;

}



int main()

{

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

    for(int i = 1 ; i <= n ; i++ ) To[read()] = i ;

    build( 1 , 1 , n ) ;

    for(int i = n ; i >= 1 ; i-- ){

        int now = Ask( 1 , 1 , n , To[i] + 1 , min( To[i] + k - 1 , n ) ) ;

        if( now != inf ) add( To[i] , To[now] ) ;

        now = Ask( 1 , 1 , n , max( 1 , To[i] - k + 1 ) , To[i] - 1 ) ;

        if( now != inf ) add( To[i] , To[now] ) ;

        update( 1 , 1 , n , To[i] , i ) ;

    }

    topo() ;

    for(int i = 1 ; i <= n ; i++ ) printf("%d\n" , Ans[i] ) ;

    return 0 ;

}