#include <bits/stdc++.h>
using namespace std;
int n, mag[15][2], cnt[1 << 15][2];
long long X, Y, res, a[200000];
vector<long long> primes;
long long euclid(long long a, long long b) {
  if (a < b) swap(a, b);
  while (b) {
    long long tmp = a % b;
    a = b;
    b = tmp;
  }
  return a;
}
void genPrimes(long long x) {
  for (long long i = 2; i <= 1000000 && i * i <= x; i++) {
    if (x % i == 0) primes.push_back(i);
    while (x % i == 0) x /= i;
  }
  vector<long long> tmp;
  for (int i = 0; i < (n); i++) {
    long long g = euclid(x, a[i]);
    if (g != 1) tmp.push_back(g);
  }
  if (!tmp.empty()) {
    sort((tmp).begin(), (tmp).end());
    primes.push_back(tmp[0]);
    while (x % tmp[0] == 0) x /= tmp[0];
    if (x != 1) primes.push_back(x);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> X >> Y;
  for (int i = 0; i < (n); i++) cin >> a[i];
  if (Y % X) {
    cout << 0 << endl;
    return 0;
  }
  genPrimes(Y);
  for (int i = 0; i < (((int)(primes).size())); i++) {
    while (X % primes[i] == 0) {
      X /= primes[i];
      mag[i][0]++;
    }
    while (Y % primes[i] == 0) {
      Y /= primes[i];
      mag[i][1]++;
    }
  }
  for (int i = 0; i < (n); i++) {
    bool gcd = 1, lcm = 1;
    int gcdmask = 0, lcmmask = 0;
    for (int j = 0; j < (((int)(primes).size())); j++) {
      int mg = 0;
      while (a[i] % primes[j] == 0) {
        a[i] /= primes[j];
        mg++;
      }
      if (mg < mag[j][0]) gcd = 0;
      if (mg > mag[j][1]) lcm = 0;
      if (mg > mag[j][0] && mag[j][0] != mag[j][1]) gcdmask |= (1 << j);
      if (mg < mag[j][1] && mag[j][0] != mag[j][1]) lcmmask |= (1 << j);
    }
    if (a[i] != 1) lcm = 0;
    if (gcd) cnt[gcdmask][0]++;
    if (lcm) cnt[lcmmask][1]++;
  }
  stack<tuple<int, int, int>> st;
  st.push(make_tuple(0, 0, 0));
  while (!st.empty()) {
    tuple<int, int, int> t = st.top();
    st.pop();
    int m1 = get<0>(t), m2 = get<1>(t), dep = get<2>(t);
    if (dep == ((int)(primes).size()))
      res += (long long)cnt[m1][0] * cnt[m2][1];
    else {
      st.push(make_tuple(m1, m2, dep + 1));
      st.push(make_tuple(m1 | (1 << dep), m2, dep + 1));
      st.push(make_tuple(m1, m2 | (1 << dep), dep + 1));
    }
  }
  cout << res << endl;
}
