#include #define rep(X,N) for(ll X = 0LL; X < (N); X++) #define ALL(V) (V).begin(),(V).end() using namespace std; typedef long long ll; const double PI = 3.1415926535897932384626; const ll MODN = 1000000007; const ll MODN2 = 998244353; const double EPS = 1e-10; //ソート済み配列に対して、指定した数以下の個数を返す関数 template int less_or_eq_count(std::vector v, T x, int size){ int ok = -1; int ng = size; while(ng - ok > 1){ int tmp = (ok + ng) / 2; if(v[tmp] <= x){ ok = tmp; }else ng = tmp; } return ok + 1; } int main(){ int n, d; cin >> n >> d; vector a(n); vector v(n); rep(i, n){ cin >> a[i]; v[i] = a[i]; } sort(ALL(v)); rep(i, n){ int tmp = a[i] - d; cout << less_or_eq_count(v, tmp, n) << "\n"; } return 0; }