#ifndef LOCAL
#pragma GCC optimize("Ofast")
#endif

#include "bits/stdc++.h"

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ld = long double;

constexpr int nax = 1000 * 1000 + 105;
constexpr int oo = numeric_limits<int>::max();
constexpr int mod = 1000 * 1000 * 1000 + 7;

template <const int&(*MinMax)(const int&, const int&), int neutral>
struct Drzewo {
  int n2;
  vector<int> drz;

  Drzewo(int n) {
    n2 = 2;
    while (n2 <= n) {
      n2 *= 2;
    }
    drz.resize(n2 * 2, neutral);
  }

  void Ustaw(int w, int val) {
    assert(0 <= w and w < n2);
    w += n2;
    drz[w] = val;
    w /= 2;
    while (w) {
      drz[w] = MinMax(drz[w * 2], drz[w * 2 + 1]);
      w /= 2;
    }
  }

  int Odczyt(int a, int b) {
    assert(0 <= a and a <= b and b < n2);
    a += n2;
    b += n2;
    int wynik = MinMax(drz[a], drz[b]);
    while ((a / 2) != (b / 2)) {
      if (a % 2 == 0) wynik = MinMax(wynik, drz[a + 1]);
      if (b % 2 == 1) wynik = MinMax(wynik, drz[b - 1]);
      a /= 2;
      b /= 2;
    }
    return wynik;
  }
};

int n, k;
int tab[nax];
int odp[nax];
vector<int> graf[nax];
int stop[nax];

void Toposort() {
  for (int i = 1; i <= n; i++) {
    for (int x : graf[i]) {
      stop[x]++;
    }
  }
  set<int> moge;
  for (int i = 1; i <= n; i++) {
    if (stop[i] == 0) {
      moge.insert(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    assert(!moge.empty());
    tab[i] = *moge.begin();
    moge.erase(moge.begin());
    for (int x : graf[tab[i]]) {
      stop[x]--;
      if (stop[x] == 0) {
        moge.insert(x);
      }
    }
  }
  assert(moge.empty());
}

void BudujGraf() {
  debug() << imie(range(tab + 1, tab + n + 1));
  Drzewo<std::min<int>, +oo> prawo(n);
  for (int i = n; i >= 1; i--) {
    const int above = prawo.Odczyt(tab[i], min(tab[i] + k - 1, n));
    const int below = prawo.Odczyt(max(tab[i] - k + 1, 1), tab[i]);
    prawo.Ustaw(tab[i], i);
    if (above != +oo) {
      graf[tab[i]].push_back(tab[above]);
    }
    if (below != +oo) {
      graf[tab[i]].push_back(tab[below]);
    }
  }

  Drzewo<std::max<int>, -oo> lewo(n);
  for (int i = 1; i <= n; i++) {
    const int above = lewo.Odczyt(tab[i], min(tab[i] + k - 1, n));
    const int below = lewo.Odczyt(max(tab[i] - k + 1, 1), tab[i]);
    lewo.Ustaw(tab[i], i);
    if (above != -oo) {
      graf[tab[above]].push_back(tab[i]);
    }
    if (below != -oo) {
      graf[tab[below]].push_back(tab[i]);
    }
  }
}

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    tab[x] = i;
  }
  BudujGraf();
  Toposort();
  for (int i = 1; i <= n; i++) {
    odp[tab[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", odp[i]);
  }
  return 0;
}


Measured memory_bytes: 60160