import bisect _,D,*A = map(int,open(0).read().split()) B = sorted(A) for a in A: if a <= D: print(0) else: C = B[:B.index(a)] print(bisect.bisect_right(C, a-D))