import bisect n,d = map(int,input().split()) A = [int(input()) for i in range(n)] ans = A.copy() A.sort() for i in range(n): x = ans[i] ans[i] = bisect.bisect_right(A, x-d) for i in ans: print(i)