#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N, D; pair A[200000]; int ans[200000]; int main() { cin >> N >> D; rep(i, N) { int a; cin >> a; A[i] = { a,i }; } sort(A, A + N); rep(i, N) { int l = 0, r = i + 1; while (l + 1 < r) { int m = (l + r) / 2; if (A[i].first - A[m - 1].first >= D) l = m; else r = m; } ans[A[i].second] = l; } rep(i, N) cout << ans[i] << endl; return 0; }