#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, d; scanf("%lld%lld", &n, &d); if (n < 2) { printf("0\n"); return 0; } map m; vector a(n); for (int i = 0; i < n; ++i) { ll ai; scanf("%lld", &ai); a[i] = ai; ++m[ai]; } map mconv; for (const auto& im : m) { if (im.first <= d) { mconv[im.first] = 0; continue; } auto iml = m.upper_bound(im.first - d); if (iml != m.begin()) mconv[im.first] = (--iml)->first; } map mc; ll prev{ m.begin()->first }; for (const auto& im : m) { mc[im.first] = 0; if (im.first == m.begin()->first) continue; else if (im.first <= d) { prev = im.first; continue; } mc[im.first] = mc[prev]; auto iml = m.upper_bound(mconv[prev]); auto imr = m.upper_bound(mconv[im.first]); for (auto imt = iml; imt != imr; ++imt) { mc[im.first] += imt->second; } prev = im.first; } ll res; for (int i = 0; i < n; ++i) { res = mc[a[i]]; printf("%lld\n", res); } return 0; }