n, d = map(int, raw_input().split()) a = sorted([(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])