#include using namespace std; #define rep(i,n) for(int i = 0; i < n; i++) using ll = long long; using graph = vector>; const ll mod = 1000000007; const int INF = 1001001001; int main(){ int n, d; cin >> n >> d; vector> ID(n); vector a(n), sorted(n); vector ans(n); for(int i = 0; i < n; i++){ cin >> a[i]; ID[i] = make_pair(a[i], i); } sorted = a; sort(sorted.begin(), sorted.end()); sort(ID.begin(), ID.end()); for(int i = 0; i < n; i++){ if(i >= 1 && ID[i].first == ID[i-1].first){ ans[ID[i].second] = ans[ID[i-1].second]; continue; } //cout << sorted[i] - d << endl; int cnt = upper_bound(sorted.begin(), sorted.end(), sorted[i] - d) - sorted.begin(); ans[ID[i].second] = cnt; } for(int i = 0; i < n; i++) cout << ans[i] << endl; }