#include #include #include #include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; constexpr int MOD = 1e9 + 7; constexpr ll MOD_LL = ll(1e9 + 7); int main(void) { int n, d; cin >> n >> d; vector a(n), tmp; for(int i = 0; i < n; ++i) { cin >> a[i]; } tmp = a; sort(a.begin(), a.end()); map ret; for(auto& x : a) { ret[x] = upper_bound(a.begin(), a.end(), x - d) - a.begin(); } for(auto& x : tmp) { cout << ret[x] << endl; } return 0; }