#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int n, dp[1 << 16];
long long x, y, a[N], ans;
vector<long long> v;
vector<pair<long long, int>> primex, primey, TEMP;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long findsqr(long long temp) {
  long long l = 1, r = 1e8, ans = 0;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (mid * mid <= temp) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return ans;
}
void factor(long long a, vector<pair<long long, int>>& prime) {
  for (int i = 2; i <= 10 * N; i++) {
    if (a % i) continue;
    int temp = 0;
    while (a % i == 0) {
      a /= i;
      temp++;
    }
    prime.push_back({i, temp});
  }
  if (a == 1) return;
  long long temp = findsqr(a);
  if (temp * temp == a) {
    prime.push_back({temp, 2});
    return;
  }
  for (int i = 0; i < n; i++) {
    temp = gcd(::a[i], a);
    if (temp == a || temp == 1) continue;
    if (temp > a / temp) temp = a / temp;
    prime.push_back({temp, 1});
    prime.push_back({a / temp, 1});
    return;
  }
  prime.push_back({a, 1});
}
int main() {
  scanf("%d%lld%lld", &n, &x, &y);
  if (y % x) {
    puts("0");
    return 0;
  }
  for (int i = 0; i < n; i++) scanf("%lld", a + i);
  factor(y, TEMP);
  long long tempx = x, tempy = y;
  for (auto i : TEMP) {
    int lolx = 0, loly = 0;
    while (tempx % i.first == 0) {
      tempx /= i.first;
      lolx++;
    }
    while (tempy % i.first == 0) {
      tempy /= i.first;
      loly++;
    }
    if (lolx == loly) continue;
    primex.push_back({i.first, lolx});
    primey.push_back({i.first, loly});
    v.push_back(i.first);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (a[i] % x) continue;
    int msk = 0;
    int j = 0;
    long long temp = a[i];
    for (auto k : primex) {
      while (v[j] != k.first) j++;
      int lol = 0;
      while (temp % k.first == 0) {
        temp /= k.first;
        lol++;
      }
      msk |= ((k.second < lol) << j);
    }
    dp[msk]++;
  }
  for (int i = 0; i < v.size(); i++)
    for (int msk = 0; msk < (1 << v.size()); msk++)
      if (msk & (1 << i)) dp[msk] += dp[msk ^ (1 << i)];
  for (int i = 0; i < n; i++) {
    if (y % a[i]) continue;
    int msk = 0;
    int j = 0;
    long long temp = a[i];
    for (auto k : primey) {
      while (v[j] != k.first) j++;
      int lol = 0;
      while (temp % k.first == 0) {
        temp /= k.first;
        lol++;
      }
      msk |= ((k.second > lol) << j);
    }
    ans += dp[msk ^ ((1 << v.size()) - 1)];
  }
  cout << ans << endl;
}
