#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3", "omit-frame-pointer", "inline")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,fma,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
const long long mod = 1000000007;
mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
const int mxN = 260;
int l[mxN], r[mxN];
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(time(NULL));
  cout << fixed << setprecision(9);
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < 256; i++) l[i] = r[i] = i;
    for (int i = 0; i < n; i++) {
      int to = max(0, r[p[i]] - k + 1);
      for (; to <= p[i]; to++)
        if (r[p[i]] - l[to] + 1 <= k) break;
      int a = l[to], b = r[p[i]];
      cout << a << " \n"[i + 1 == n];
      for (int j = a; j <= b; j++) l[j] = a, r[j] = b;
    }
  }
  return 0;
}
