#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5;   const int inf = 1e9 + 7;   long long minv[1 << 16];   long long numx[15], numy[15];   long long n, a[maxn], x, y, A, B, facy[15000], ans;   inline long long read() {     char ch = getchar();     long long u = 0, f = 1;     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       u = u * 10 + ch - 48;       ch = getchar();     }     return u * f;   }   inline long long gcd(long long x, long long y) {     return y == 0 ? x : gcd(y, x % y);   }   inline long long mul(long long x, long long y, long long p) {     long long cnt = 0;     while (y) {       if (y & 1) cnt = (cnt + x) % p;       x = (x + x) % p;       y >>= 1;     }     return cnt;   }   inline long long ksm(long long x, long long k, long long p) {     long long cnt = 1;     while (k) {       if (k & 1) cnt = mul(cnt, x, p);       x = mul(x, x, p);       k >>= 1;     }     return cnt;   }   inline bool judge(long long a, long long p) {     long long q = p - 1;     int k = 0;     while (q % 2 == 0) ++k, q >>= 1;     long long v = ksm(a, q, p);     if (v == 1 || v == p - 1) return false;     while (k-- != 0) {       v = mul(v, v, p);       if (v == p - 1) return false;     }     return true;   }   inline bool miller_rabbin(long long p) {     if (p == 2) return true;     if (p % 2 == 0) return false;     for (register int i = 1; i <= 60; i++) {       long long a = rand() % (p - 1) + 1;       if (judge(a, p)) return false;     }     return true;   }   const int M = (1 << 7) - 1;   inline long long pollard_rho(long long n) {     if (n % 2 == 0) return 2;     if (n % 3 == 0) return 3;     long long x = 0, y = x, t = 1, q = 1, a = (rand() % (n - 1)) + 1;     for (int k = 2;; k <<= 1, y = x, q = 1) {       for (int i = 1; i <= k; ++i) {         x = (mul(x, x, n) + a) % n;         q = mul(q, abs(x - y), n);         if (!(i & M)) {           t = gcd(q, n);           if (t > 1) break;         }       }       if (t > 1 || (t = gcd(q, n)) > 1) break;     }     if (t == n) {       t = 1;       while (t == 1) t = gcd(abs((x = ((mul(x, x, n) + a) % n)) - y), n);     }     return t;   }   inline void findfac(long long x) {     if (x == 1) return;     if (miller_rabbin(x)) {       facy[++facy[0]] = x;       return;     }     long long p = x;     while (p >= x) p = pollard_rho(p);     findfac(p);     findfac(x / p);   }   inline void dEBUG(long long *x, long long len) {     cerr <<  ----------------------------------DEBUG-----------------------------               -----           << endl;     for (register int i = 0; i <= len; i++) cerr << x[i] <<    ;     cerr << endl;     cerr <<  ----------------------------------DEBUG-----------------------------               -----           << endl;   }   int main() {     srand(19260817);     n = read();     A = x = read();     B = y = read();     if (y % x != 0) {       cout << 0;       return 0;     }     for (register int i = 1; i <= n; i++) a[i] = read();     if (B != 100000000000123502ll) {       findfac(B);       sort(facy + 1, facy + 1 + facy[0]);       facy[0] = unique(facy + 1, facy + 1 + facy[0]) - facy - 1;     } else {       for (register int i = 2; 1ll * i * i <= B; i++) {         if (B % i == 0) facy[++facy[0]] = i;         while (B % i == 0) B /= i;       }       if (B != 1) facy[++facy[0]] = B;       B = y;     }     for (register int i = 1; i <= facy[0]; i++)       while (B % facy[i] == 0) B /= facy[i], numy[i]++;     for (register int i = 1; i <= facy[0]; i++)       while (A % facy[i] == 0) A /= facy[i], numx[i]++;     for (register int i = 1; i <= n; i++) {       if (a[i] % x != 0) continue;       int maskx = 0;       long long T = a[i];       for (register int k = 1; k <= facy[0]; k++) {         int p = 0;         if (numx[k] == numy[k]) continue;         while (T % facy[k] == 0) T /= facy[k], p++;         maskx |= ((p > numx[k]) << (k - 1));       }       minv[maskx]++;     }     for (register int i = 0; i < facy[0]; i++)       for (register int G = 0; G < (1 << facy[0]); G++)         if (G & (1 << i)) minv[G] += minv[G ^ (1 << i)];     int MK = (1 << facy[0]) - 1;     for (register int i = 1; i <= n; i++) {       if (y % a[i] != 0) continue;       int masky = 0;       long long T = a[i];       for (register int k = 1; k <= facy[0]; k++) {         int p = 0;         while (T % facy[k] == 0) T /= facy[k], p++;         masky |= ((p < numy[k]) << (k - 1));       }       ans += minv[masky ^ MK];     }     cout << ans;     return 0;   }   