#include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { int n, d; cin >> n >> d; vector a(n); map num; int mx = 0; for(int i = 0; i < n; i++){ cin >> a[i]; num[a[i]]++; mx = max(mx, a[i]); } bool ok = false; for(int i = 0; i <= mx; i++){ if(num[i] != 0 && !ok){ ok = true; }else if(num[i] == 0 && ok){ num[i] = num[i-1]; }else if(num[i] != 0 && ok){ num[i] += num[i-1]; } } for(int i = 0; i < n; i++){ if(a[i] -d >= 0){ cout << num[a[i]-d] << endl; }else{ cout << 0 << endl; } } return 0; }