# Header {{{
def assert(p)
  raise 'Assertion Failed' unless p
end

# Constants {{{
INF = 10**9
# }}}

# IO {{{
class MyIO
  def initialize
    @input = $stdin
    @output = $stdout
  end

  # @param filename [String]
  def set_input(filename)
    @input = File.open(filename, 'r')
  end

  def set_output(filename)
    @output = File.open(filename, 'w')
  end

  def intl
    splitl.map(&:to_i)
  end

  def splitl
    @input.gets.chomp.split(' ')
  end

  def gets
    @input.gets.chomp
  end

  def puts(*args)
    @output.puts(*args)
  end
end

io = MyIO.new
# }}}

# }}}

# io.set_input('inputs/3.txt')

n, t = io.intl
levels = []
n.times do
  levels << io.gets.to_i
end
levels.sort!

if n == 1
  puts 1
  exit 0
end

n_impossible_pairs = 0
i, j = 0, 0
while i < n
  if levels[i] - levels[j] > t
    n_impossible_pairs += n - i
    j += 1
  else
    i += 1
  end
end

all_comb = n.downto(1).reduce(:*)
impossible_comb = (n-1).downto(1).reduce(:*) * n_impossible_pairs

puts all_comb - impossible_comb

# vim: foldmethod=marker