N,D = map(int,input().split()) A = {} l = [0]*N for i in range(N): a = int(input()) A.update({a:0}) l[i] = a ls = sorted(l) count,k = 0,0 for i in range(N-1,-1,-1): count = 0 for j in range(i,-1,-1): if ls[i] - ls[j] >= D: k = j count = j+1 break A[ls[i]] = count for i in range(N): print(A[l[i]])