N,D = map(int,input().split()) A = [] for i in range(N): a = int(input()) A.append( (a,i) ) import bisect ans = [0] * N A.sort() for i in range(N): ind = bisect.bisect_right(A , ( A[i][0]-D , float("inf") ) ) ans[A[i][1]] = ind for i in range(N): print (ans[i])