#include <bits/stdc++.h>
using namespace std;
int data[100001];
int num[100001];
int grp[100001];
int n;
int k;
void kFlat() {
  num[0] = 1;
  grp[0] = 0;
  for (int i = 1; i < n; i++) {
    int max = 1;
    int g = i;
    for (int j = 0; j < i; j++) {
      if (abs(data[i] - data[j]) <= k) {
        if (num[j] >= max) {
          max = num[j] + 1;
          g = j;
        }
      }
    }
    num[i] = max;
    grp[i] = g;
  }
  int maxIndex = 0;
  int maxValue = 0;
  for (int i = 0; i < n; i++) {
    if (num[i] > maxValue) {
      maxValue = num[i];
      maxIndex = i;
    }
  }
  stack<int> s;
  do {
    s.push(data[maxIndex]);
    maxIndex = grp[maxIndex];
    maxValue--;
  } while (maxValue > 0);
  while (!s.empty()) {
    printf("%d ", s.top());
    s.pop();
  }
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &(data[i]));
  }
  kFlat();
  return 0;
}
