#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000;
const int INF = 1e9 + 5;
long long gcd(long long a, long long b) {
  if (!b) return a;
  while ((a %= b) && (b %= a))
    ;
  return a + b;
}
void nope() {
  cout << "0\n";
  exit(EXIT_SUCCESS);
}
long long N, X, Y;
long long a[MAXN + 5], v1[MAXN + 5], v2[MAXN + 5], mask1[MAXN + 5],
    mask2[MAXN + 5], dp[(1 << 20)];
vector<long long> pf;
bool is_prime(long long x) {
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
bool test(long long n, long long x) {
  long long g = gcd(n, x);
  if (g != 1 && g != n) {
    pf.push_back(g);
    pf.push_back(n / g);
    return true;
  }
  return false;
}
void factorize(long long n, vector<long long> &pf) {
  for (long long p = 2; p <= (long long)1e6 + 5; p++) {
    while (n % p == 0) {
      pf.push_back(p);
      n /= p;
    }
  }
  long long sq = round(sqrt(n)) + 0.5;
  if (n == 1)
    return;
  else if (sq * sq == n && is_prime(sq)) {
    pf.push_back(sq);
    pf.push_back(sq);
  } else {
    if (test(n, X)) return;
    if (test(n, Y)) return;
    for (int i = 0; i < N; i++)
      if (test(n, a[i])) return;
    pf.push_back(n);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> X >> Y;
  if (Y % X != 0) nope();
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    v1[i] = a[i] % X != 0 ? -1 : a[i] / X;
    v2[i] = Y % a[i] != 0 ? -1 : Y / a[i];
  }
  factorize(Y / X, pf);
  sort(pf.begin(), pf.end());
  pf.resize(unique(pf.begin(), pf.end()) - pf.begin());
  assert(pf.size() <= 20);
  int m = (1 << pf.size()) - 1;
  for (int i = 0; i < N; i++) {
    mask1[i] = mask2[i] = 0;
    if (v1[i] != -1) {
      for (int j = 0; j < pf.size(); j++) {
        if (v1[i] % pf[j] == 0) {
          mask1[i] |= (1 << j);
        }
      }
    }
    if (v2[i] != -1) {
      for (int j = 0; j < pf.size(); j++) {
        if (v2[i] % pf[j] == 0) {
          mask2[i] |= (1 << j);
        }
      }
      dp[mask2[i] ^ m]++;
    }
  }
  for (int i = pf.size() - 1; i >= 0; i--) {
    for (int S = 0; S <= m; S++) {
      if (~S >> i & 1) {
        dp[S] += dp[S ^ 1 << i];
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (v1[i] != -1) {
      ans += dp[mask1[i]];
    }
  }
  cout << ans << "\n";
  return 0;
}
