n, d = map(int, input().split()) alst = [[int(input()), i] for i in range(n)] alst.sort() ans = [0 for _ in range(n)] for a, i in alst: l = 0 r = n while r != l: pos = (r + l) // 2 if a - d >= alst[pos][0]: l = pos + 1 else: r = pos ans[i] = l print(*ans, sep = "\n")