import bisect n, d = map(int, input().split()) a = [[int(input()), i] for i in range(n)] a = sorted(a) bi_a = [a[i][0] for i in range(n)] ans = [0] * n for val, ind in a: ans[ind] = bisect.bisect_right(bi_a, val - d) for val in ans: print(val)