// Slower C++ solution:
#include<cstdio>

#include<queue>

#include<cstring>

#include<algorithm>

using namespace std;

#define MAXN 500010

int a[MAXN],n,k,ans[MAXN];

int t[MAXN*4];

int Query(int i,int l,int r,int L,int R)

{

	if(L>R) return t[0];

	if(L<=l&&r<=R) return t[i];

	int mid=(l+r)/2;

	if(R<=mid) return Query(i<<1,l,mid,L,R);

	if(L>mid) return Query(i<<1|1,mid+1,r,L,R);

	return min(Query(i<<1,l,mid,L,R),Query(i<<1|1,mid+1,r,L,R));

}

void Change(int i,int l,int r,int p,int w)

{

	if(l==r)

	{

		t[i]=w;

		return;

	}

	int mid=(l+r)/2;

	if(p<=mid) Change(i<<1,l,mid,p,w);

	else Change(i<<1|1,mid+1,r,p,w);

	t[i]=min(t[i<<1|1],t[i<<1]);

}

int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c,d[MAXN];

void AddEdge(int u,int v)

{

	d[v]++;c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;

}

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

void TopSort()

{

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

	int tot=0;

	while(!Q.empty())

	{

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

		ans[u]=++tot;

		for(int i=Adj[u];i;i=nxt[i])

			if(!--d[V[i]])

				Q.push(V[i]);

	}

}

int main()

{

//	freopen("swap.in","r",stdin);

//	freopen("swap.out","w",stdout);

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

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

	{

		int x;

		scanf("%d",&x);

		a[x]=i;

	}

	if(k<=1)

	{

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

			printf("%d\n",i);

		return 0;

	}

	memset(t,0x3f3f3f3f,sizeof t);

	for(int i=n;i;i--)

	{

		int x=Query(1,1,n,a[i]+1,min(a[i]+k-1,n));

		if(x<1e9) AddEdge(a[i],a[x]);

		x=Query(1,1,n,max(a[i]-k+1,1),a[i]-1);

		if(x<1e9) AddEdge(a[i],a[x]);

		Change(1,1,n,a[i],i);

	}

	TopSort();

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

		printf("%d\n",ans[i]);

}

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

using namespace std;



int read(){

	int a = 0; char c = getchar(); while(!isdigit(c)) c = getchar();

	while(isdigit(c)){a = a * 10 + c - 48; c = getchar();} return a;

}



const int _ = 2e6 + 7;

int N , K , P[_] , tmp[_]; priority_queue < int > q;



#define mid ((l + r) >> 1)

#define lch (x << 1)

#define rch (x << 1 | 1)

int mn[_] , mrk[_];

void mark(int x , int v){mn[x] += v; mrk[x] += v;}

void down(int x){if(mrk[x]){mark(lch , mrk[x]); mark(rch , mrk[x]); mrk[x] = 0;}}



void ins(int x , int l , int r , int t){

	if(l == r){mn[x] = 0; return;}

	down(x); mn[x] = 0; mid >= t ? ins(lch , l , mid , t) : ins(rch , mid + 1 , r , t);

}



void add(int x , int l , int r , int L , int R , int v){

	if(l >= L && r <= R) return mark(x , v);

	down(x);

	if(mid >= L) add(lch , l , mid , L , R , v);

	if(mid < R) add(rch , mid + 1 , r , L , R , v);

	mn[x] = min(mn[lch] , mn[rch]);

}



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

	if(mn[x]) return;

	if(l == r){mn[x] = 1e9; q.push(l); return;}

	down(x); find(lch , l , mid); find(rch , mid + 1 , r); mn[x] = min(mn[lch] , mn[rch]);

}



int main(){

	N = read(); K = read(); for(int i = 1 ; i <= N ; ++i) P[read()] = i;

	for(int i = 1 ; i <= N ; ++i){

		add(1 , 1 , N , max(1 , P[i] - K + 1) , min(N , P[i] + K - 1) , 1);	ins(1 , 1 , N , P[i]);

	}

	find(1 , 1 , N); vector < int > ans;

	while(!q.empty()){

		int t = q.top(); q.pop(); ans.push_back(t);

		add(1 , 1 , N , max(1 , t - K + 1) , min(N , t + K - 1) , -1); find(1 , 1 , N);

	}

	reverse(ans.begin() , ans.end());

	for(int i = 0 ; i < ans.size() ; ++i) P[ans[i]] = i + 1;

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

	return 0;

}