#!/usr/bin/env python3

def main():
  with open("game.in", "r") as fin:
    n, K = map(int, fin.readline().split())
    a = list(map(int, fin.readline().split()))
  a.sort()
  m = 0
  cnt = list()
  val = list()
  for i in range(n):
    if (i == 0) or (a[i] != a[i - 1]):
      m += 1
      cnt.append(1)
      val.append(a[i])
    else:
      cnt[m - 1] += 1

  ans = 0
  i = 0
  j = 1
  cnt1 = 0
  cnt2 = 0
  while (i < m):
    border = val[i] * K
    while (j < m) and (border >= val[j]):
      cnt1 += 1
      if (cnt[j] >= 2):
        cnt2 += 1
      j += 1

    if (cnt[i] >= 3):
      ans += 1
    if (cnt[i] >= 2):
      ans += 3 * cnt1
    if (cnt[i] >= 1):
      ans += 3 * (cnt2 + cnt1 * (cnt1 - 1))

    if (i + 1 == j):
      i += 1
      j += 1
    else:
      i += 1
      cnt1 -= 1
      if (cnt[i] >= 2):
        cnt2 -= 1

  with open("game.out", "w") as fout:
    fout.write(str(ans) + "\n")


if __name__ == "__main__":
    main()

