#include <bits/stdc++.h>   using namespace std;   vector<long long> primer;   long long mul(long long x, long long y, long long mod) {     long long s = 0;     for (; y; y /= 2, x = (x + x) % mod)       if (y & 1) s = (s + x) % mod;     return s;   }   long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }   long long power(long long x, long long y, long long mo) {     long long s = 1;     for (; y; y /= 2, x = mul(x, x, mo))       if (y & 1) s = mul(s, x, mo);     return s;   }   bool isPrime(long long x) {     if (x == 2) return 1;     for (int T = 10; T; T--) {       long long a = rand() % (x - 2) + 2;       if (power(a, x - 1, x) != 1) return 0;       int p = x - 1;       for (; p % 2 == 0;) {         p /= 2;         long long v = power(a, p, x);         if (mul(v, v, x) == 1 && v != 1 && v != x - 1) return 0;       }     }     return 1;   }   long long pollard(long long n, int c) {     long long i = 0, k = 2, x = rand() % (n - 1) + 1, y = x;     for (;;) {       x = (mul(x, x, n) + c) % n;       long long g = gcd((y - x + n) % n, n);       if (g != 1 && g != n) return g;       if (x == y) return n;       if ((++i) == k) y = x, k <<= 1;     }   }   void getPrimes(long long n, vector<long long> &p) {     if (n == 1) return;     if (isPrime(n)) {       p.push_back(n);       return;     }     long long d = n;     for (int i = 2; d == n; i++) d = pollard(n, i);     getPrimes(d, p);     getPrimes(n / d, p);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   inline void moreprime() {     int start = primer.back() + 1;     if (primer.size() % 10000 == 0)       cout << primer.size() <<     << primer.back() << endl;     while (true) {       for (unsigned int i = 0; i < primer.size(); i++) {         if (start % primer[i] == 0) break;         if (primer[i] * primer[i] > start) {           primer.push_back(start);           return;         }       }       start++;     }   }   vector<long long> defactor(long long a) {     vector<long long> result;     getPrimes(a, result);     sort(result.begin(), result.end());     vector<long long> rs;     if (result.size() > 0) rs.push_back(result[0]);     for (int i = 1; i < result.size(); i++) {       if (result[i] != result[i - 1]) rs.push_back(result[i]);     }     return rs;   }   int getbit(long long a, const vector<long long> &factors) {     int bit = 0;     for (unsigned int i = 0; i < factors.size(); i++) {       if (a % factors[i] == 0) {         a /= factors[i];         bit |= 1 << i;       }     }     return bit;   }   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     int n;     long long x, y;     primer.push_back(2);     cin >> n >> x >> y;     if (y % x != 0) {       printf( 0 );       return 0;     }     vector<long long> factors = defactor(y / x);     vector<long long> a(40000, 0), b(40000, 0);     int maxa = 0, maxb = 0;     int v;     long long num;     for (int i = 0; i < n; i++) {       cin >> num;       if (num % x == 0) {         v = getbit(num / x, factors);         a[v]++;         maxa = max(maxa, v);       }       if (y % num == 0) {         v = getbit(y / num * gcd(y / num, num) / gcd(y / num, x), factors);         b[v]++;         maxb = max(maxb, v);       }     }     long long count = 0;     for (int i = 0; i <= maxa; i++) {       if (a[i]) {         for (int j = 0; j <= maxb; j++) {           if (b[j]) {             if (!(i & j)) count += a[i] * b[j];           }         }       }     }     cout << count << endl;   }   