// 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.379957869584489x):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<queue>

#include<vector>

#define N 500010

#define P pair<int,int>

#define MP make_pair

#define fi first

#define se second

using namespace std;

P tree[N<<2];

void change(int u,int l,int r,P x)

{

	tree[u]=max(tree[u],x);

	if(l==r) return;

	int mid=(l+r)>>1;

	if(x.se<=mid) change(u<<1,l,mid,x);

	else change(u<<1|1,mid+1,r,x);

}

P answer(int u,int l,int r,int L,int R)

{

	if(L<=l && r<=R) return tree[u];

	if(R<L) return MP(0,0);

	int mid=(l+r)>>1;

	P ans=MP(0,0);

	if(L<=mid) ans=max(ans,answer(u<<1,l,mid,L,R));

	if(R>mid) ans=max(ans,answer(u<<1|1,mid+1,r,L,R));

	return ans;

}

int nxt[N<<1],to[N<<1],head[N],in[N],cnt;

int p[N];

void add(int u,int v)

{

	nxt[++cnt]=head[u];

	to[cnt]=v;

	in[v]++;

	head[u]=cnt;

}

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

int ans[N];

int main()

{

	int n,k;

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

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

	{

		int a;

		scanf("%d",&a);

		p[a]=i;

	}

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

	{

		change(1,1,n,MP(i,p[i]));

		P l=answer(1,1,n,max(1,p[i]-k+1),p[i]-1),r=answer(1,1,n,p[i]+1,min(p[i]+k-1,n));

		if(l.fi>0) add(l.se,p[i]);

		if(r.fi>0) add(r.se,p[i]);

	}

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

	int tot=0;

	while(!q.empty())

	{

		int u=q.top();

		q.pop();

		ans[u]=++tot;

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

		{

			int v=to[i];

			in[v]--;

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

		}

	}

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

	return 0;

}