#include #include using namespace std; int main(){ int N, D; cin >> N >> D; vector A(N); for (int& x : A) cin >> x; auto B = A; sort(A.begin(), A.end()); for (int x : B){ auto it = upper_bound(A.begin(), A.end(), x-D); cout << it-A.begin() << endl; } }