import bisect from collections import defaultdict n,D = map(int,input().split()) a = [int(input()) for i in range(n)] ac = a[:] ac.sort() d = defaultdict(int) for i in range(n): d[ac[i]] = bisect.bisect_right(ac,ac[i]-D) for i in range(n): print(d[a[i]])