#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(tmp.begin(), tmp.end()); for(auto& x : a) { int ans = upper_bound(tmp.begin(), tmp.end(), x - d) - tmp.begin(); cout << ans << endl; } return 0; }