#include using namespace std; int main() { int n, d; cin >> n >> d; assert(1 <= n && n <= 100000); 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.at(i) = p.at(i).first; for (int i = 0; i < n; i++) { ans.at(p.at(i).second) = upper_bound(a.begin(), a.end(), a.at(i) - d) - a.begin(); } for (int i = 0; i < n; i++) { cout << ans.at(i) << endl; } }