#include <bits/stdc++.h>
using namespace std;
long long __gcd(long long a, long long b) {
  if (not a or not b) return a | b;
  return __gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / __gcd(a, b); }
vector<long long> fast_OR_transform(vector<long long> f, bool inverse) {
  for (int i = 0; (2 << i) <= f.size(); ++i)
    for (int j = 0; j < f.size(); j += 2 << i)
      for (int k = 0; k < (1 << i); ++k)
        f[j + k + (1 << i)] += f[j + k] * (inverse ? -1 : 1);
  return f;
}
vector<long long> rev(vector<long long> A) {
  for (int i = 0; i < A.size(); i += 2) swap(A[i], A[i ^ (A.size() - 1)]);
  return A;
}
vector<long long> fast_AND_transform(vector<long long> f, bool inverse) {
  return rev(fast_OR_transform(rev(f), inverse));
}
long long LLmul(long long x, long long y, long long mod) {
  long long m = x, s = 0;
  for (; y; y >>= 1, m <<= 1, m = m >= mod ? m - mod : m)
    if (y & 1) s += m, s = s >= mod ? s - mod : s;
  return s;
}
long long powmod(long long x, long long p, long long mod) {
  long long s = 1, m = x % mod;
  for (; p; m = LLmul(m, m, mod), p >>= 1)
    if (p & 1) s = LLmul(s, m, mod);
  return s;
}
bool miller_rabin(long long n, int s = 7) {
  const long long wits[7] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
  auto witness = [=](long long a, long long n, long long u, int t) {
    long long x = powmod(a, u, n), nx;
    for (int i = 0; i < t; ++i, x = nx) {
      nx = LLmul(x, x, n);
      if (nx == 1 and x != 1 and x != n - 1) return true;
    }
    return x != 1;
  };
  if (n < 2) return 0;
  if (n & 1 ^ 1) return n == 2;
  long long u = n - 1, t = 0, a;
  while (u & 1 ^ 1) u >>= 1, ++t;
  while (s--)
    if ((a = wits[s] % n) and witness(a, n, u, t)) return 0;
  return 1;
}
long long pollard_rho(long long n) {
  auto f = [=](long long x, long long n) { return LLmul(x, x, n) + 1; };
  if (n & 1 ^ 1) return 2;
  while (true) {
    long long x = rand() % (n - 1) + 1, y = 2, d = 1;
    for (int sz = 2; d == 1; y = x, sz <<= 1)
      for (int i = 0; i < sz and d <= 1; ++i)
        x = f(x, n), d = __gcd(abs(x - y), n);
    if (d and n - d) return d;
  }
}
vector<pair<long long, int>> factor(long long m) {
  vector<pair<long long, int>> ans;
  while (m != 1) {
    long long cur = m;
    while (not miller_rabin(cur)) cur = pollard_rho(cur);
    ans.emplace_back(cur, 0);
    while (m % cur == 0) ++ans.back().second, m /= cur;
  }
  sort(ans.begin(), ans.end());
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long a, n, X, Y;
  cin >> n >> X >> Y;
  if (Y % X) cout << 0 << '\n', exit(0);
  auto factor_Y = factor(Y);
  int m = factor_Y.size();
  assert(m <= 20);
  vector<long long> left(1 << m, 0), right(1 << m, 0);
  vector<pair<long long, int>> factor_X;
  for (auto T : factor_Y) {
    static long long C_X = X;
    long long p, t;
    tie(p, t) = T;
    factor_X.emplace_back(p, 0);
    while (C_X % p == 0) C_X /= p, ++factor_X.back().second;
  }
  for (int i = 0; i < n; ++i) {
    cin >> a;
    int maskl = 0, maskr = 0;
    bool can_left = a % X == 0, can_right = Y % a == 0;
    for (int j = 0; j < m; ++j) {
      long long p, tx, ty, ta = 0;
      tie(p, tx) = factor_X[j];
      tie(p, ty) = factor_Y[j];
      if (tx == ty) continue;
      while (a % p == 0) ++ta, a /= p;
      maskl |= (tx < ta) << j;
      maskr |= (ty > ta) << j;
    }
    if (can_left) ++left[maskl];
    if (can_right) ++right[maskr];
  }
  left = fast_AND_transform(left, false),
  right = fast_AND_transform(right, false);
  for (int i = 0; i < (1 << m); ++i) left[i] *= right[i];
  cout << fast_AND_transform(left, true)[0] << '\n';
}
