#include <bits/stdc++.h>

using namespace std;

const int N = 5e5 + 5;

int n, k, top;
int p[N], q[N];

map <int, int> M;
list <int> L[N];

int main() {
    cin >> n >> k;
    M[0] = 0;
    for(int i = 1; i <= n; i++) scanf("%d", &p[i]), q[p[i]] = i;
    for(int i = 1; i < k; i++) M[p[i]] = i;
    for(int i = 1; i <= n; i++) L[i].push_back(i);
    for(int i = 1; i <= n; i++) {
        if(i + k - 1 <= n) M[p[i + k - 1]] = i + k - 1;
        auto it = -- M.find(p[i]);
        L[it -> second].splice(L[it -> second].end(), L[i]);
        M.erase(p[i]);
    }
    for(auto x : L[0]) p[++top] = x;
    for(int i = 1; i <= n; i++) q[p[i]] = i;
    for(int i = 1; i <= n; i++) printf("%d\n", q[i]);
    return 0;
}