#include using namespace std; using ll = long long; int main() { int n,d; cin >> n >> d; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } auto b = a; sort(b.begin(), b.end()); for (int i = 0; i < n; i++) { int x = a[i] - d; auto ans = upper_bound(b.begin(), b.end(), x) - b.begin(); cout << ans << endl; } }