Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.

He wants to know how many subsequences of length three can be selected from a, so that they form a geometric progression with common ratio k.

A subsequence of length three is a combination of three such indexes i1, i2, i3, that 1 ≤ i1 < i2 < i3 ≤ n. That is, a subsequence of length three are such groups of three elements that are not necessarily consecutive in the sequence, but their indexes are strictly increasing.

A geometric progression with common ratio k is a sequence of numbers of the form b·k0, b·k1, ..., b·kr - 1.

Polycarp is only three years old, so he can not calculate this number himself. Help him to do it.

Input

The first line of the input contains two integers, n and k (1 ≤ n, k ≤ 2·105), showing how many numbers Polycarp's sequence has and his favorite number.

The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — elements of the sequence.

Output

Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio k.

Examples

Input

5 2
1 1 2 2 4


Output

4

Input

3 1
1 1 1


Output

1

Input

10 3
1 2 6 2 3 6 9 18 3 9


Output

6

Note

In the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.
#include <bits/stdc++.h>
using namespace std;
int64_t const inf = 1e9 + 7;
int64_t check(vector<int64_t> const& k0, vector<int64_t> const& k1,
              vector<int64_t> const& k2) {
  int64_t result = 0;
  int64_t i0 = 0;
  int64_t i1 = 0;
  int64_t i2 = 0;
  int64_t s0 = k0.size();
  int64_t s1 = k1.size();
  int64_t s2 = k2.size();
  while (true) {
    int64_t q0 = i0 < s0 ? k0[i0] : inf;
    int64_t q1 = i1 < s1 ? k1[i1] : inf;
    int64_t q2 = i2 < s2 ? k2[i2] : inf;
    int64_t m = min(min(q0, q1), q2);
    if (m == inf) break;
    if (q1 == m) {
      result += i0 * (s2 - i2);
    }
    if (q0 == m) i0 += 1;
    if (q1 == m) i1 += 1;
    if (q2 == m) i2 += 1;
  }
  return result;
}
int main(int, char**) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
  int64_t N, k;
  cin >> N >> k;
  vector<int64_t> a;
  a.reserve(N);
  int64_t zeros = 0;
  for (int64_t i = 0; i < N; ++i) {
    int64_t t;
    cin >> t;
    if (t != 0)
      a.push_back(t);
    else
      zeros += 1;
  }
  int64_t n = a.size();
  int64_t result = 0;
  for (int64_t i = 1; i < zeros; ++i) {
    result += i * (zeros - i - 1);
  }
  if (k > 1) {
    vector<map<int64_t, vector<int64_t>>> steps(40);
    for (int64_t i = 0; i < n; ++i) {
      int64_t ai = a[i];
      if (ai % k == 0) {
        int64_t rai = ai / k;
        for (int64_t j = steps.size() - 1; j > 0; --j) {
          if (steps[j - 1].count(rai) > 0) steps[j][ai].push_back(i);
        }
      }
      steps[0][ai].push_back(i);
    }
    set<int64_t> processed;
    for (int64_t j = 2; j < steps.size(); ++j) {
      for (auto const& p : steps[j]) {
        if (processed.count(p.first) > 0) continue;
        processed.insert(p.first);
        int64_t k2 = p.first;
        int64_t k1 = k2 / k;
        int64_t k0 = k1 / k;
        result += check(steps[j - 2][k0], steps[j - 1][k1], p.second);
      }
    }
  } else {
    map<int64_t, int64_t> counts;
    for (int64_t i = 0; i < n; ++i) {
      counts[a[i]] += 1;
    }
    for (auto const& p : counts) {
      for (int64_t i = 1; i < p.second; ++i) {
        result += i * (p.second - i - 1);
      }
    }
  }
  cout << result << endl;
  return 0;
}
