#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const unordered_set<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class S, class T>
ostream& operator<<(ostream& os, const unordered_map<S, T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const multiset<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class S, class T>
ostream& operator<<(ostream& os, const map<S, T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
void dbs(string str, T t) {
  cerr << str << " : " << t << "\n";
}
template <class T, class... S>
void dbs(string str, T t, S... s) {
  long long idx = str.find(',');
  cerr << str.substr(0, idx) << " : " << t << ",";
  dbs(str.substr(idx + 1), s...);
}
template <class T>
void prc(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y / 2, x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
long long mulMod(long long a, long long b, long long c) {
  long long x = 0, y = a % c;
  while (b > 0) {
    if (b % 2 == 1) x = (x + y) % c;
    y = (y * 2) % c;
    b /= 2;
  }
  return x % c;
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long Mod(long long a, long long b, long long p) {
  long long res = 1;
  long long x = a % p;
  while (b) {
    if (b & 1) {
      res = mulMod(res, x, p);
    }
    x = mulMod(x, x, p);
    b /= 2;
  }
  return res % p;
}
bool millerTest(long long d, long long s, long long n) {
  long long a = rand() % (n - 4) + 2;
  long long x = Mod(a, s, n);
  if (x == 1 or x == n - 1) return true;
  for (int r = 1; r < d; r++) {
    x = mulMod(x, x, n);
    if (x == 1) return false;
    if (x == n - 1) return true;
  }
  return false;
}
bool isPrime(long long n, int k = 20) {
  if (n <= 1 || n == 4) return false;
  if (n <= 3) return true;
  if (n % 2 == 0) return false;
  long long s = n - 1, d = 0;
  while (s % 2 == 0) {
    s /= 2;
    d++;
  }
  for (int i = 0; i < k; i++) {
    if (millerTest(d, s, n) == false) return false;
  }
  return true;
}
long long pollard_rho(long long n) {
  if (n % 2 == 0) return 2;
  long long x = rand() % n + 1;
  long long c = rand() % n + 1;
  long long y = x;
  long long g = 1;
  while (g == 1) {
    x = (mulMod(x, x, n) + c) % n;
    y = (mulMod(y, y, n) + c) % n;
    y = (mulMod(y, y, n) + c) % n;
    g = gcd((((x - y) > 0) ? (x - y) : -(x - y)), n);
  }
  return g;
}
map<long long, long long> MAP;
void factorize(long long n) {
  if (n == 1) return;
  if (isPrime(n)) {
    MAP[n]++;
    return;
  }
  long long divisor = pollard_rho(n);
  factorize(divisor);
  factorize(n / divisor);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, x, y;
  cin >> n >> x >> y;
  if (y % x) {
    cout << 0;
    return 0;
  }
  map<long long, long long> haha;
  map<long long, long long> lol;
  factorize(x);
  haha = MAP;
  MAP.clear();
  factorize(y);
  lol = MAP;
  MAP.clear();
  factorize(y / x);
  vector<long long> xx;
  vector<long long> yy;
  long long i;
  for (i = 0; i < n; i++) {
    long long k;
    cin >> k;
    if (k % x == 0) {
      long long mask = 0;
      long long j = 0;
      for (auto v : MAP) {
        long long factor = v.first;
        long long cnt = 0;
        long long temp = k;
        while (temp % factor == 0) cnt++, temp /= factor;
        if (cnt > haha[v.first]) mask |= (1LL << j);
        j++;
      }
      xx.push_back(mask);
    }
    if (y % k == 0) {
      long long mask = 0;
      long long j = 0;
      for (auto v : MAP) {
        long long factor = v.first;
        long long cnt = 0;
        long long temp = k;
        while (temp % factor == 0) cnt++, temp /= factor;
        if (cnt < lol[v.first]) mask |= (1LL << j);
        j++;
      }
      yy.push_back(mask);
    }
  }
  long long cnt = MAP.size();
  long long dp[1LL << cnt];
  for (i = 0; i < (1LL << cnt); i++) dp[i] = 0;
  for (auto v : yy) dp[v]++;
  for (i = 0; i < cnt; i++) {
    long long j;
    for (j = 0; j < (1LL << cnt); j++) {
      if (j & (1 << i)) dp[j] += dp[j ^ (1LL << i)];
    }
  }
  long long ans = 0;
  for (auto v : xx) ans += dp[((1 << cnt) - 1) ^ v];
  cout << ans;
}
