// Copyright (C) 2017 SYCstudio.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

#define ll long long
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))
#define mcp(Arr,Brr) memcpy(Arr,Brr,sizeof(Arr))

const int maxN=500100;
const int inf=2147483647;

int n,K;
int cnt=0;
int Head[maxN];
int Next[maxN*4];
int V[maxN*4];
int Arr[maxN];
int Pos[maxN];//Pos[i]表示数i在Arr中的位置
int New_Pos[maxN];
int Seg[maxN*4];
int Degree[maxN];
priority_queue<int,vector<int>,less<int> > Q;

int read();
int Query(int now,int l,int r,int ql,int qr);
void Update(int now,int l,int r,int pos,int key);
void Add_Edge(int u,int v);
void Outp(int now,int l,int r);

int main()
{
	mem(Seg,127);
	mem(Head,-1);
	n=read();
	K=read();
	for (int i=1;i<=n;i++)
	{
		Arr[i]=read();
		Pos[Arr[i]]=i;
	}
	for (int i=n;i>=1;i--)
	{
		//Outp(1,1,n);
		//cout<<endl;
		int mn=inf;
		//if (Pos[i]!=1)
		//cout<<max(1,Pos[i]-K+1)<<" "<<Pos[i]<<endl;
		mn=Query(1,1,n,max(1,Pos[i]-K+1),Pos[i]);
		//cout<<mn<<endl;
		if (mn<=n)
			Add_Edge(Pos[mn],Pos[i]);
		mn=inf;
		//if (Pos[i]!=n)
		mn=Query(1,1,n,Pos[i],min(Pos[i]+K-1,n));
		if (mn<=n)
			Add_Edge(Pos[mn],Pos[i]);
		//cout<<mn<<endl;
		Update(1,1,n,Pos[i],i);
	}
	for (int i=1;i<=n;i++)
		if (Degree[i]==0)
			Q.push(i);
	//cout<<Q.empty()<<endl;
	for (int i=n;i>=1;i--)
	{
		int x=Q.top();
		//cout<<x<<endl;
		Q.pop();
		New_Pos[i]=x;
		for (int j=Head[x];j!=-1;j=Next[j])
		{
			Degree[V[j]]--;
			if (Degree[V[j]]==0)
				Q.push(V[j]);
		} 
	}
	/*
	for (int i=1;i<=n;i++)
		cout<<New_Pos[i]<<" ";
	cout<<endl;
	//*/
	for (int i=1;i<=n;i++)
		Arr[New_Pos[i]]=i;
	for (int i=1;i<=n;i++)
		printf("%d\n",Arr[i]);
	fclose(stdin);
	fclose(stdout);
	return 0;
}

int read()
{
	int x=0,k=1;
	char ch=getchar();
	while (((ch<'0')||(ch>'9'))&&(ch!='-'))
		ch=getchar();
	if (ch=='-')
	{
		k=-1;
		ch=getchar();
	}
	while ((ch>='0')&&(ch<='9'))
	{
		x=x*10+ch-48;
		ch=getchar();
	}
	return x*k;
}

int Query(int now,int l,int r,int ql,int qr)
{
	//cout<<now<<" "<<l<<" "<<r<<" "<<ql<<" "<<qr<<" "<<Seg[now]<<endl;
	if ((l==ql)&&(r==qr))
		return Seg[now];
	int mid=(l+r)/2;
	if (qr<=mid)
		return Query(now*2,l,mid,ql,qr);
	if (ql>=mid+1)
		return Query(now*2+1,mid+1,r,ql,qr);
	return min(Query(now*2,l,mid,ql,mid),Query(now*2+1,mid+1,r,mid+1,qr));
}

void Update(int now,int l,int r,int pos,int key)
{
	if (l==r)
	{
		Seg[now]=key;
		return;
	}
	int mid=(l+r)/2;
	if (pos<=mid)
		Update(now*2,l,mid,pos,key);
	if (pos>=mid+1)
		Update(now*2+1,mid+1,r,pos,key);
	Seg[now]=min(Seg[now*2],Seg[now*2+1]);
	return;
}

void Add_Edge(int u,int v)
{
	cnt++;
	Next[cnt]=Head[u];
	Head[u]=cnt;
	V[cnt]=v;
	Degree[v]++;
}

void Outp(int now,int l,int r)
{
	if (l==r)
	{
		cout<<Seg[now]<<" ";
		return;
	}
	int mid=(l+r)/2;
	Outp(now*2,l,mid);
	Outp(now*2+1,mid+1,r);
	return;
}


Measured memory_bytes: 32896