import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, D = map(int, readline().split()) A = np.array(read().split(), np.int64) A_sort = A.copy() A_sort.sort() ans = np.searchsorted(A_sort, A - D, side='right') print('\n'.join(map(str, ans.tolist())))