#include using namespace std; using ll = long long; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; ll d; cin >> n >> d; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector ids(n); iota(ids.begin(), ids.end(), 0); sort(ids.begin(), ids.end(), [&](int i1, int i2){ return a[i1] < a[i2]; }); vector ans(n, 0); vector v; for (int i : ids) { ans[i] = upper_bound(v.begin(), v.end(), a[i] - d) - v.begin(); v.push_back(a[i]); } for (int i = 0; i < n; i++) { cout << ans[i] << newl; } return 0; }