#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<ctime>
using namespace std;

const int N=1e5+1e3+7;

int n,k,a[N],pos[N];

void solve1()
{
	int tt;
	if(n<=2000)
		tt=300000;
	else
		tt=4500;
	for(int j=1;j<=tt;j++)
	{
		for(int i=1;i<n;i++)
			if(pos[i]-pos[i+1]>=k)
				swap(a[pos[i]],a[pos[i+1]]),swap(pos[i],pos[i+1]);
	}
}

int main()
{
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	scanf("%d%d",&n,&k);
	if(k==1)
	{
		for(int i=1;i<=n;i++)
			printf("%d\n",i);
		return 0;
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),pos[a[i]]=i;
	solve1();
	for(int i=1;i<=n;i++)
		printf("%d\n",a[i]);
}