import bisect n,d=map(int,raw_input().split()) a=sorted([(input(),i)for i in range(n)]) x=[0]*n for i in range(n):x[a[i][1]]=bisect.bisect_left(a,(a[i][0]-d,2000000000)) for i in x:print(i)