#include <bits/stdc++.h>   using namespace std;   long long n, k, l, r, sz, i, len, q, p, mid, anspos, ans[1000001];   long long mxl, mxr;   long long pos[1000001], t[1000001], pr[100001];   struct Pair {     long long pos;     long long x;     long long d;   };   Pair a[100001], b[100001];   bool cmp(Pair p1, Pair p2) { return p1.x < p2.x; }   bool cmd(Pair p1, Pair p2) { return p1.pos < p2.pos; }   long long binl(long long L, long long R, long long height) {     long long otv = -1;     while (L <= R) {       mid = L + R;       mid /= 2;       if (b[mid].x > height)         R = mid - 1;       else         otv = mid, L = mid + 1;     }     return otv;   }   long long binr(long long L, long long R, long long height) {     long long otv = -1;     while (L <= R) {       mid = L + R;       mid /= 2;       if (b[mid].x < height)         L = mid + 1;       else         otv = mid, R = mid - 1;     }     return otv;   }   long long tree(long long L, long long R) {     long long nn = 0;     while (L <= R) {       if (L % 2 == 1) nn = max(nn, t[L]);       if (R % 2 == 0) nn = max(nn, t[R]);       L = (L + 1) / 2;       R = (R - 1) / 2;     }     return nn;   }   void update(long long x) {     x /= 2;     while (x) {       t[x] = max(t[x * 2], t[x * 2 + 1]);       x /= 2;     }   }   int main() {     cin >> n >> k;     sz = 1;     while (sz < n) sz *= 2;     for (i = 1; i <= n; i++) {       cin >> a[i].x;       a[i].pos = i;       b[i] = a[i];     }     sort(b + 1, b + n + 1, cmp);     for (int i = 1; i <= n; i++) pos[b[i].pos] = i, pr[i] = b[i].pos;     for (int i = 1; i <= n; i++) {       int l = binl(1, pos[i] - 1, a[i].x - k);       int r = binr(pos[i] + 1, n, a[i].x + k);       int mxl = 0, mxr = 0;       if (l > 0) mxl = tree(sz, l + sz - 1);       if (r > 0) mxr = tree(r + sz - 1, n + sz - 1);       t[pos[i] + sz - 1] = max(mxl, mxr) + 1;       update(pos[i] + sz - 1);       a[pr[pos[i]]].d = t[pos[i] + sz - 1];     }     sort(b + 1, b + n + 1, cmd);     cout << t[1] << endl;     for (int i = 1; i <= n; i++) {       if (a[i].d == t[1]) {         p = i;         break;       }     }     ans[++q] = p;     for (int j = p; j >= 1; j--) {       if (a[j].d == a[p].d - 1 && abs(a[j].x - a[p].x) >= k) {         ans[++q] = j;         p = j;       }     }     for (int i = q; i >= 1; i--) cout << ans[i] <<    ;     return 0;   }   