from bisect import bisect from collections import Counter n, d = map(int, input().split()) a = [int(input()) for _ in range(n)] c = sorted(list(Counter(a).items())) keys, values = [-10**20], [0] for i, j in c: keys.append(i) values.append(values[-1]+j) for x in a: print(values[bisect(keys, x-d)-1])