N,D = map(int,input().split()) A = [int(input()) for _ in range(N)] B = A.copy() B.sort() for a in A: x = a - D if B[0] > x: print(0) continue start = 0 end = N while end - start > 1: mid = end + start >> 1 if B[mid] <= x: start = mid else: end = mid print(start + 1)