N, D = gets.split.map(&:to_i) A = N.times.map { gets.to_i } sorted = A.sort A.each do |a| t = a - D idx = sorted.bsearch_index { |x| x >= t + 1 } puts idx end