#include using namespace std; int main() { int n, d; cin >> n >> d; vector a(n); vector v(n); for(int i = 0; i < n; i++) { cin >> a[i]; v[i] = a[i]; } sort(v.begin(), v.end()); int check; int ok, ng, mid; for(int i = 0; i < n; i++) { check = a[i] - d; ok = -1; ng = n; while(abs(ok - ng) != 1) { mid = (ok + ng) / 2; if(v[mid] <= check) ok = mid; else ng = mid; } cout << ok + 1 << endl; } return 0; }