#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n];
  int colors[256];
  memset(colors, -1, sizeof(colors));
  vector<int> ans;
  int curCol = 0;
  int nums[256];
  memset(nums, 0, sizeof(nums));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (colors[a[i]] != -1) {
      ans.push_back(colors[a[i]]);
    } else {
      int curNum = 0;
      int metColor = -1;
      for (int j = a[i]; j >= 0; j--) {
        if (colors[j] != -1) {
          curNum += nums[colors[j]];
          metColor = colors[j];
          break;
        }
        curNum++;
      }
      if (i == 0) {
        for (int j = a[i]; j >= max(0, a[i] - k + 1); j--) {
          nums[curCol]++;
          colors[j] = curCol;
        }
        ans.push_back(0);
      } else {
        if (curNum > k) {
          curCol++;
          for (int j = a[i]; j >= max(0, a[i] - k + 1); j--) {
            if (colors[j] != -1) {
              break;
            }
            nums[curCol]++;
            colors[j] = curCol;
          }
          ans.push_back(curCol);
        } else {
          if (metColor == -1) {
            curCol++;
            metColor = curCol;
          }
          for (int j = a[i]; j >= 0; j--) {
            if (colors[j] != -1) {
              break;
            }
            nums[metColor]++;
            colors[j] = metColor;
          }
          ans.push_back(metColor);
        }
      }
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    for (int j = 0; j < 256; j++) {
      if (colors[j] == ans[i]) {
        cout << j << " ";
        break;
      }
    }
  }
  return 0;
}
