n, d = map(int, input().split()) a = sorted([(int(input()), i) for i in range(n)]) ans = [0] * n index = 0 for i in range(n): while (a[i][0] - a[index][0] >= d): index = index + 1 ans[a[i][1]] = index for i in range(n): print(ans[i])