#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int colors[300] = {0};
  for (int i = 0; i < n; i++) {
    int pix;
    cin >> pix;
    if (!colors[pix]) {
      int canGoLeftSteps = k - 1;
      int nowOn = pix;
      int saw = 0;
      while (canGoLeftSteps && nowOn > 0) {
        nowOn--;
        canGoLeftSteps--;
        if (colors[nowOn]) {
          if (k - colors[nowOn] >= (pix - nowOn)) {
            for (int j = nowOn + 1; j <= pix; j++) {
              colors[j] = colors[j - 1] + 1;
            }
            saw = 1;
          } else {
            nowOn++;
          }
          break;
        }
      }
      if (!saw) {
        colors[nowOn] = 1;
        for (int j = nowOn + 1; j <= pix; j++) {
          colors[j] = colors[j - 1] + 1;
        }
      }
    }
    cout << pix - colors[pix] + 1 << " ";
  }
  cout << endl;
  return 0;
}
