#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
int n;
long long X, Y;
long long a[MAXN];
vector<long long> atoms;
void process(long long x) {
  long long ox = x;
  for (int i = (0); i < (((int)(atoms).size())); ++i) {
    while (x != 1) {
      if (x % atoms[i] == 0) {
        x /= atoms[i];
        continue;
      }
      long long g = gcd(x, atoms[i]);
      if (g == 1) break;
      x /= g;
      vector<long long> q;
      q.push_back(atoms[i] / g);
      q.push_back(g);
      while (((int)(q).size()) >= 2) {
        long long a = q[((int)(q).size()) - 2], c = q[((int)(q).size()) - 1],
                  b = gcd(a, c);
        if (b == 1) {
          atoms.push_back(c);
          q.pop_back();
          continue;
        }
        if (a == c) {
          q.pop_back();
          continue;
        }
        if (c == b) {
          q[((int)(q).size()) - 2] = a / b, q[((int)(q).size()) - 1] = b;
          continue;
        }
        if (a == b) {
          q[((int)(q).size()) - 2] = b, q[((int)(q).size()) - 1] = c / b;
          continue;
        }
        q[((int)(q).size()) - 2] = a / b, q[((int)(q).size()) - 1] = b,
                              q.push_back(c / b);
      }
      atoms[i] = q[0];
    }
  }
  if (x != 1) atoms.push_back(x);
}
long long solve() {
  if (Y % X != 0) return 0;
  atoms.clear();
  process(Y / X);
  for (int i = (0); i < (n); ++i) process(gcd(Y / X, a[i]));
  vector<int> acnt(1 << ((int)(atoms).size()), 0);
  vector<int> bcnt(1 << ((int)(atoms).size()), 0);
  for (int i = (0); i < (n); ++i) {
    if (a[i] % X != 0) continue;
    int mask = 0;
    for (int k = (0); k < (((int)(atoms).size())); ++k)
      if ((a[i] / X) % atoms[k] == 0) mask |= 1 << k;
    ++acnt[mask];
  }
  for (int j = (0); j < (n); ++j) {
    if (Y % a[j] != 0) continue;
    int mask = 0;
    for (int k = (0); k < (((int)(atoms).size())); ++k)
      if ((Y / a[j]) % atoms[k] == 0) mask |= 1 << k;
    ++bcnt[mask];
  }
  vector<int> asum = acnt;
  for (int k = (0); k < (((int)(atoms).size())); ++k)
    for (int mask = (0); mask < (((int)(asum).size())); ++mask)
      if ((mask & (1 << k)) != 0) asum[mask] += asum[mask ^ (1 << k)];
  long long ret = 0;
  for (int mask = (0); mask < (1 << ((int)(atoms).size())); ++mask)
    ret +=
        (long long)asum[(1 << ((int)(atoms).size())) - 1 - mask] * bcnt[mask];
  return ret;
}
void run() {
  scanf("%d%lld%lld", &n, &X, &Y);
  for (int i = (0); i < (n); ++i) scanf("%lld", &a[i]);
  printf("%lld\n", solve());
}
int main() {
  run();
  return 0;
}
