#include <bits/stdc++.h>
const int maxp = 256;
int sz[maxp], fa[maxp];
int findfa(int x) {
  if (x == fa[x])
    return x;
  else
    return fa[x] = findfa(fa[x]);
}
void uni(int x, int y) {
  x = findfa(x);
  y = findfa(y);
  if (x == y) return;
  if (x > y) std::swap(x, y);
  sz[x] += sz[y];
  fa[y] = x;
}
int main(int argc, char const *argv[]) {
  for (int i = 0; i < maxp; i++) {
    fa[i] = i;
    sz[i] = 1;
  }
  int n, k;
  scanf("%d%d", &n, &k);
  while (n--) {
    int x;
    scanf("%d", &x);
    int r = findfa(x);
    if (sz[r] == k) {
      printf("%d ", r);
      continue;
    }
    for (int low = std::max(r - k + 1, 0); low <= x; low++) {
      if (sz[findfa(low)] + sz[r] + x - low <= k + 1) {
        for (int c = low + 1; c <= x; c++) uni(low, c);
        printf("%d ", findfa(low));
        goto label;
      }
    }
    printf("%d ", r);
  label:;
  }
  return 0;
}
