#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> inline bool chmax(T& a, const T& b) {if (a<b) {a=b; return true;} return false;} template<class T> inline bool chmin(T& a, const T& b) {if (b<a) {a=b; return true;} return false;} const int INTINF = 1000001000; const int INTMAX = 2147483647; const ll LLMAX = 9223372036854775807; const ll LLINF = 1000000000000000000; #include "atcoder/lazysegtree.hpp" using S_t = int; using F_t = int; S_t op (S_t a, S_t b) { return a+b; } S_t e() { return 0; } S_t mapping(F_t f, S_t x) { return x + f; } F_t composition(F_t f, F_t g) { return g + f; } F_t id(){ return 0; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N, S; cin >> N >> S; vector<int>P(N); for(int i=0; i<N ; i++) cin >> P[i]; vector<int> cord; for(int i=0; i<N; i++) { cord.push_back(P[i]-S); cord.push_back(P[i]+S+1); cord.push_back(P[i]); } sort(cord.begin(), cord.end()); cord.erase(unique(cord.begin(), cord.end()), cord.end()); atcoder::lazy_segtree<S_t,op,e,F_t,mapping,composition,id> seg(cord.size()); for(int i=0; i<N; i++) { // |P_i - P_J| <= S // -S <= P_i - P_j <= S // P_i - S <= P_j <= P_i + S int idx = lower_bound(cord.begin(), cord.end(), P[i]) - cord.begin(); assert(binary_search(cord.begin(), cord.end(), P[i])); seg.apply(idx, idx+1, 1); } vector<int>ans; for(int i=0; i<N; i++) { int l_idx = lower_bound(cord.begin(), cord.end(), P[i]-S) - cord.begin(); int r_idx = lower_bound(cord.begin(), cord.end(), P[i]+S+1) - cord.begin(); int sum = seg.prod(l_idx, r_idx); if (sum == 1 ) { ans.push_back(i+1); } } cout << ans.size() << endl; for(int i=0; i<int(ans.size()); i++) { cout << ans[i] << " \n"[i == int(ans.size())-1]; } return 0; }