#int(input()) #map(int, input().split()) #list(map(int, input().split())) N, D = map(int, input().split()) A = [0] * N for i in range(N): A[i] = int(input()) B = sorted(A) import bisect ans = [0] * N for i in range(N): t = bisect.bisect(B, A[i]-D) ans[i] = t for i in range(N): print(ans[i])