#include <bits/stdc++.h>
using namespace std;
long long x, y, a[200000];
int n;
long long mul(long long a, long long b, long long mod) {
  long long ret = 0;
  for (a %= mod, b %= mod; b != 0;
       b >>= 1, a <<= 1, a = a >= mod ? a - mod : a) {
    if (b & 1) {
      ret += a;
      if (ret >= mod) ret -= mod;
    }
  }
  return ret;
}
void exgcd(long long x, long long y, long long &g, long long &a, long long &b) {
  if (y == 0)
    g = x, a = 1, b = 0;
  else
    exgcd(y, x % y, g, b, a), b -= (x / y) * a;
}
long long llgcd(long long x, long long y) {
  if (x < 0) x = -x;
  if (y < 0) y = -y;
  if (!x || !y) return x + y;
  long long t;
  while (x % y) t = x, x = y, y = t % y;
  return y;
}
long long inverse(long long x, long long p) {
  long long g, b, r;
  exgcd(x, p, g, r, b);
  if (g < 0) r = -r;
  return (r % p + p) % p;
}
long long mpow2(long long x, long long y, long long mod) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = mul(ret, x, mod);
    y >>= 1, x = mul(x, x, mod);
  }
  return ret % mod;
}
int isPrime(long long p) {
  if (p < 2 || !(p & 1)) return 0;
  if (p == 2) return 1;
  long long q = p - 1, a, t;
  int k = 0, b = 0;
  while (!(q & 1)) q >>= 1, k++;
  for (int it = 0; it < 2; it++) {
    a = rand() % (p - 4) + 2;
    t = mpow2(a, q, p);
    b = (t == 1) || (t == p - 1);
    for (int i = 1; i < k && !b; i++) {
      t = mul(t, t, p);
      if (t == p - 1) b = 1;
    }
    if (b == 0) return 0;
  }
  return 1;
}
long long pollard_rho(long long n, long long c) {
  long long x = 2, y = 2, i = 1, k = 2, d;
  while (true) {
    x = (mul(x, x, n) + c);
    if (x >= n) x -= n;
    d = llgcd(x - y, n);
    if (d > 1) return d;
    if (++i == k) y = x, k <<= 1;
  }
  return n;
}
void factorize(long long x, vector<long long> &f) {
  long long z = 5;
  z = 2;
  while (x % z == 0) {
    f.push_back(z);
    x /= z;
  }
  z = 3;
  while (x % z == 0) {
    f.push_back(z);
    x /= z;
  }
  z = 5;
  long long limit = sqrt(x);
  long long inc = 2;
  while (z <= limit) {
    if (x % z == 0) {
      f.push_back(z);
      x /= z;
      limit = sqrt(x);
    } else {
      z += inc;
      inc ^= 6;
    }
  }
  if (x > 1) f.push_back(x);
}
void llfactorize(long long n, vector<long long> &f) {
  if (n == 1) return;
  if (n < 1e+9) {
    factorize(n, f);
    return;
  }
  if (isPrime(n)) {
    f.push_back(n);
    return;
  }
  long long d = n;
  for (int i = 2; d == n; i++) d = pollard_rho(n, i);
  llfactorize(d, f);
  llfactorize(n / d, f);
}
vector<int> factorize2(long long x, vector<long long> &primes) {
  vector<int> powers(primes.size() + 1, 0);
  for (int i = 0; i < primes.size(); i++) {
    long long p = primes[i];
    while (x % p == 0) {
      powers[i]++;
      x /= p;
    }
  }
  if (x > 1) powers[primes.size()] = 1;
  return powers;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> x >> y;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (y % x > 0) {
    cout << 0;
    return 0;
  }
  vector<long long> y_factors;
  llfactorize(y, y_factors);
  vector<long long> primes;
  vector<int> ypowers;
  sort(y_factors.begin(), y_factors.end());
  for (long long f : y_factors) {
    if (primes.size() == 0 || primes[primes.size() - 1] != f) {
      primes.push_back(f);
      ypowers.push_back(1);
    } else {
      ypowers[ypowers.size() - 1]++;
    }
  }
  auto xpowers = factorize2(x, primes);
  int k = primes.size();
  vector<int> ai, aj;
  for (int i = 0; i < n; i++) {
    auto p = factorize2(a[i], primes);
    int x = 0;
    for (int j = 0, l = 0; j < k; j++) {
      if (p[j] < xpowers[j]) {
        x = -1;
        break;
      }
      if (ypowers[j] != xpowers[j]) {
        if (p[j] == xpowers[j]) x |= 1 << l;
        l++;
      }
    }
    if (x != -1) {
      ai.push_back(x);
    }
    x = 0;
    if (p[k] == 0) {
      for (int j = 0, l = 0; j < k; j++) {
        if (p[j] > ypowers[j]) {
          x = -1;
          break;
        }
        if (ypowers[j] != xpowers[j]) {
          if (p[j] == ypowers[j]) x |= 1 << l;
          l++;
        }
      }
      if (x != -1) {
        aj.push_back(x);
      }
    }
  }
  long long cnt = 0;
  int ones = 1;
  for (int i = 0; i < k; i++)
    if (ypowers[i] != xpowers[i]) ones <<= 1;
  ones--;
  sort(ai.begin(), ai.end());
  sort(aj.begin(), aj.end());
  vector<pair<int, long long>> ajv, aiv;
  for (int i = 0, n = 0; i <= ai.size(); i++, n++) {
    if (i > 0 && (i == ai.size() || ai[i] != ai[i - 1])) {
      aiv.push_back(make_pair(ai[i - 1], n));
      n = 0;
    }
  }
  for (int i = 0, n = 0; i <= aj.size(); i++, n++) {
    if (i > 0 && (i == aj.size() || aj[i] != aj[i - 1])) {
      ajv.push_back(make_pair(aj[i - 1], n));
      n = 0;
    }
  }
  for (auto aai : aiv)
    for (auto aaj : ajv)
      if ((aai.first | aaj.first) == ones) cnt += aai.second * aaj.second;
  cout << cnt;
  return 0;
}
