// 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.93341077673085x):
#include<cstdio>

#include<iostream>

#include<cstring>

#include<vector>

#include<queue>

#define RG register

using namespace std;

const int N=5e5+10;

struct dabt{

	int next,to;

}e[N<<2];

int head[N],k,n,m,tree[N<<2],ru[N],pos[N],p[N],cnt,ans[N];

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

inline void add(int from,int to){e[++k]=(dabt){head[from],to}; head[from]=k; ru[to]++;}

inline int read(){

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

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

	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}

	return x*f;}

inline int mi(int a,int b){return a<b ? a : b;}

inline int mx(int a,int b){return a>b ? a : b;}

int sum(int l,int r,int st,int ed,int o)

{

	if(st<=l && r<=ed) return tree[o];

//	printf("%d %d %d %d %d\n",l,r,st,ed,o);

	if(l==r) return 2e9;

	int mid=l+(r-l)/2, ans=2e9;

	if(mid>=st) ans=mi(ans,sum(l,mid,st,ed,o<<1));

	if(mid<ed) ans=mi(ans,sum(mid+1,r,st,ed,o<<1|1));

	return ans;

}

void upd(int l,int r,int pos,int kk,int o)

{

	if(l==r) 

	{

		tree[o]=kk;

		return ;

	}

	int mid=l+(r-l)/2;

	if(pos<=mid) upd(l,mid,pos,kk,o<<1);

	else upd(mid+1,r,pos,kk,o<<1|1);

	tree[o]=mi(tree[o<<1],tree[o<<1|1]);

}

inline void topo()

{

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

	while(!pn.empty())

	{

		int x=pn.top(); pn.pop(); ans[x]=++cnt;

		for(int i=head[x];i;i=e[i].next)

		{

			int v=e[i].to;

			if(--ru[v]==0) pn.push(v);

		}

	}

}

int main()

{

//	freopen("Wide Swap.in","r",stdin);

//	freopen("Wide Swap.out","w",stdout);

	n=read(); m=read();

	for(int i=1;i<=(n<<2);i++) tree[i]=2e9;

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

	{

		pos[p[i]=read()]=i;

	}

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

	{

		x=sum(1,n,pos[i]+1,mi(pos[i]+m-1,n),1);

		if(x<2e9) add(pos[i],pos[x]);

		x=sum(1,n,mx(pos[i]-m+1,1),pos[i]-1,1);

		if(x<2e9) add(pos[i],pos[x]);

		upd(1,n,pos[i],i,1);

	}

	topo();

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

	//fclose(stdin); fclose(stdout);

	return 0;

}