#include <bits/stdc++.h>
using namespace std;
vector<int> g(256, -1), len(256, -1);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int x = 0, i; x < n; x++) {
    cin >> i;
    if (g[i] != -1)
      cout << g[i] << ' ';
    else {
      int m = max(0, i - k + 1);
      while (true) {
        if (g[m] == -1) {
          break;
          g[m] = m;
          len[m] = 1;
        } else if ((k - len[g[m]] + m) >= i) {
          m = g[m];
          break;
        }
        m++;
      }
      len[m] = i - m + 1;
      for (int y = m; y <= i; y++) {
        g[y] = m;
      }
      cout << m << ' ';
    }
  }
  return 0;
}
