N,D = map(int, input().split()) A = [int(input()) for _ in range(N)] for i in range(N): A[i] = (A[i], i) A.sort() ans = [0]*N i = 0 for j in range(N): while i < j and A[j][0]-A[i][0] >= D: i += 1 ans[A[j][1]] = i for a in ans: print(a)