n, d = map(int, input().split()) A = [] for i in range(n): A.append((int(input()), i)) A.sort(key=lambda x: x[0], reverse=True) ANS = [0 for _ in range(n)] right = 0 for left in range(n): while right < n and A[left][0] - A[right][0] < d: right += 1 ANS[A[left][1]] = n - right for ans in ANS: print(ans)