#include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; int main() { int n, d; cin >> n >> d; vector v(n), vv(n); for (auto &&i : v) scanf("%d", &i); vv = v; sort(vv.begin(),vv.end()); for (int i = 0; i < n; ++i) { cout << upper_bound(vv.begin(),vv.end(), v[i]-d) - vv.begin() << "\n"; } return 0; }