#include <bits/stdc++.h>
inline int read() {
  register int x = 0, f = 1;
  register char ch = getchar();
  for (; !isdigit(ch); f = ch == '-' ? -1 : 1, ch = getchar())
    ;
  for (; isdigit(ch); x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar())
    ;
  return x * f;
}
int buf[15];
inline void write(int x) {
  register int cnt = 0;
  while (x) buf[++cnt] = x % 10 + 48, x /= 10;
  while (cnt) putchar(buf[cnt--]);
  puts("");
}
int n, k, p[260];
bool b[260];
int main() {
  n = read();
  k = read();
  for (register int i = 1; i <= n; i++) {
    register int x = read(), t = -1;
    for (register int j = x; j >= 0 && t < 0; j--)
      if (b[j]) t = j;
    if (t < 0)
      if (x >= k)
        b[x - k + 1] = 1, p[x - k + 1] = x,
                  printf("%d%c", x - k + 1, i == n ? '\n' : ' ');
      else
        b[0] = 1, p[0] = x, printf("0%c", i == n ? '\n' : ' ');
    else if (t + k - 1 < x) {
      register int tmp = (x - k + 1 > p[t] + 1 ? x - k + 1 : p[t] + 1);
      b[tmp] = 1;
      p[tmp] = x;
      printf("%d%c", tmp, i == n ? '\n' : ' ');
    } else
      p[t] = (p[t] > x ? p[t] : x), printf("%d%c", t, i == n ? '\n' : ' ');
  }
  return 0;
}
