import java.io.*;
import java.util.*;

public class battle_va {
	public static void main(String[] args) {
		new battle_va().run();
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	int[] fenv;

	public void add(int x) {
		for (int i = x; i < fenv.length; i = i | (i + 1)) {
			fenv[i]++;
		}
	}

	public int get(int x) {
		int ans = 0;
		for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
			ans += fenv[i];
		}
		return ans;
	}

	public int getFree(int k) {
		int l = -1;
		int r = fenv.length;
		while (l < r - 1) {
			int m = (l + r) / 2;
			if (m + 1 - get(m) >= k) {
				r = m;
			} else {
				l = m;
			}
		}
		return r;
	}

	public void solve() throws IOException {
		int n = nextInt();
		int k = nextInt();

		fenv = new int[n];

		int[] a = new int[n];
		int[] inv = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt() - 1;
			inv[a[i]] = Math.max(i - get(a[i]) - k, 0);
			add(a[i]);
		}

		int[] ans = new int[n];
		Arrays.fill(fenv, 0);
		for (int i = 0; i < inv.length; i++) {
			int pos = getFree(inv[i] + 1);
			ans[pos] = i + 1;
			add(pos);
		}

		for (int i = 0; i < ans.length; i++) {
			out.print(ans[i] + " ");
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader("battle.in"));
			out = new PrintWriter("battle.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
