#include using namespace std; int main() { int n, d; cin >> n >> d; assert(1 <= n && n <= 200000); assert(1 <= d && d <= 1000000000); vector> p; for (int i = 0; i < n; i++) { int a_i; cin >> a_i; assert(1 <= a_i && a_i <= 1000000000); p.emplace_back(a_i, i); } sort(p.begin(), p.end()); vector a(n), ans(n); for (int i = 0; i < n; i++) a[i] = p[i].first; for (int i = 0; i < n; i++) { ans[p[i].second] = upper_bound(a.begin(), a.end(), a[i] - d) - a.begin(); } for (int i = 0; i < n; i++) { cout << ans[i] << "\n"; } }