///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<double, null_type, less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#define int long long
typedef long long ll;
typedef double dd;
typedef long double ldd;
typedef pair <int, int> pii;
typedef pair <pii , int> ppii;
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
#define all(x) x.begin() , x.end()
#define debug(x) cerr<< #x << " = " << x << endl
#define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
#define uop(x, y) pii(min(x, y), max(x, y))
#define mem(a, b) memset(a, b, sizeof a)
#define sq(x) (x) * (x)
#define out return cout << -1 << endl, 0
const int mx = 5e5 + 10;
int n, seg[4 * mx], lazy[4 * mx], fen[mx], ind[mx], ans[mx];
void shift(int v, int lc, int rc){
	seg[lc] += lazy[v];
	seg[rc] += lazy[v];
	lazy[lc] += lazy[v];
	lazy[rc] += lazy[v];
	lazy[v] = 0;
	return;
}
void add(int l , int r , int val, int b = 0, int e = n, int ind = 1){
//	cout << "df" << endl;
	if(r <= b || e <= l){
	//	cout << "out1" << endl;
		return;
	}
	if(l <= b && e <= r){
	//	cout << "out2" << endl;
		seg[ind] += val;
		lazy[ind] += val;
		return;
	}
	shift(ind, 2 * ind, 2 * ind + 1);
	int mid = (e + b) / 2;
	add(l, r, val, b, mid, 2 * ind);
	add(l, r, val, mid, e, 2 * ind + 1);
	seg[ind] = min(seg[2 * ind] , seg[2 * ind + 1]);
//	cout << ind << " " << seg[ind] << endl;
	return;
}
int minimum(int l = 0, int r = n, int ind = 1){
//	cout << l << " " << r << " " << ind << " " << seg[ind] << " " << seg[2 * ind + 1] << " " << lazy[ind] << endl;
	if(r - l == 1)
		return l;
	shift(ind , 2 * ind, 2 * ind + 1);
	int mid = (l + r) / 2;
	if(!seg[2 * ind + 1]){
//		cout << "ah" << endl;
		return minimum(mid, r, 2 * ind + 1);
	}
	return minimum(l, mid, 2 * ind);
}
void add(int p){
	for(p++; p <= n; p += (p & -p))
		fen[p]++;
	return;
}
int get(int p){
	int ret = 0;
	for( ; p; p -= (p & -p))
		ret += fen[p];
	return ret;
}
int get(int l, int r){
	return get(r) - get(l);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int k, a;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a;
		ind[a - 1] = i;
	}
	for(int i = n - 1; ~i; i--){
	//	cout << "gi" << " " << ind[i] << " " << ind[i] + 1 <<" " <<  get(max(0 , ind[i] - k + 1) , min(n , ind[i] + k)) << endl;
		add(ind[i] , ind[i] + 1, get(max(0 , ind[i] - k + 1) , min(n , ind[i] + k)));
		add(ind[i]);
	}
//	cout << endl;
	for(int i = 0; i < n; i++){
		int mini = minimum();
//		debug(mini);
		add(mini , mini + 1, INT_MAX);
		add(max(0 , mini - k + 1) , min(n , mini + k) , -1);
		ans[mini] = n - i;
	//	for(int i = 1; i <= 7; i++)
	//		cout << "h " << seg[i] << " " << lazy[i] << endl;
	}
	for(int i = 0; i < n; i++)
		cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 19968