#include <bits/stdc++.h>

using namespace std;

int main() {
    ifstream in("game.in");
    ofstream out("game.out");
    int n, k;
    in >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        in >> x[i];
    }
    sort(x.begin(), x.end());
    vector<pair<int, int> > a;
    a.push_back({x[0], 1});
    for (int i = 1; i < n; i++) {
        if (a.back().first == x[i]) a.back().second++;
        else  a.push_back({x[i], 1});
    }
    int cnt = 0;
    int cnt2 = 0;
    n = a.size();
    long long ans = 0;
    int r = 1;
    // cerr << n << endl;
    for (int l = 0; l < n; l++) {
        // cerr << l << " " << r << endl;
        while (r < n && a[l].first * 1LL * k >= a[r].first) {
            if (a[r].second > 1) cnt2++;
            cnt++;
            r++;
        }
        // cerr << ans << " " << cnt << " " << cnt2 << endl;
        if (a[l].second > 2) ans++;
        if (a[l].second >= 2) ans += 3 * cnt;
        if (a[l].second >= 1) ans += 3 * cnt2 + 6 * cnt * (cnt - 1) / 2;
        cnt--;
        if (a[l + 1].second > 1) cnt2--;                 
    }
    out << ans << endl;
    return 0;
}
