from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,D = map(int,input().split()) A = [int(input()) for _ in range(N)] def cle(a,D): y = len(D)-1 x = 0 if D[x]>a: return 0 if D[y]<=a: return y+1 while y-x>1: mid = (y+x)//2 if D[mid]<=a: x = mid else: y = mid return y B = A[:] B.sort() for a in A: print(cle(a-D,B))