#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int64 n, X, Y;
vector<int64> a;
int64 gcd(int64 a, int64 b) {
  while (b != 0) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
int64 isqrt(int64 n) {
  int64 lb = 0, ub = 2000000000LL;
  while (ub - lb > 1) {
    int64 mid = (ub + lb) / 2;
    if (mid * mid <= n)
      lb = mid;
    else
      ub = mid;
  }
  return lb;
}
int countFactors(int64 n, int64 k) {
  int cnt = 0;
  while (n % k == 0) {
    n /= k;
    cnt++;
  }
  return cnt;
}
vector<pair<int64, int>> factorize(int64 n) {
  assert(n > 1);
  vector<pair<int64, int>> factors;
  for (int64 m = 2; m <= 1000000; m++) {
    int cnt = 0;
    while (n % m == 0) {
      n /= m;
      cnt++;
    }
    if (cnt > 0) factors.emplace_back(m, cnt);
  }
  if (n == 1) return factors;
  int64 m = isqrt(n);
  if (m * m == n) {
    factors.emplace_back(m, 2);
    return factors;
  }
  vector<int64> numbers(a.begin(), a.end());
  numbers.push_back(X);
  for (int64 num : numbers) {
    int64 g = gcd(num, n);
    if (g == 1 or g == n) continue;
    factors.emplace_back(g, 1);
    factors.emplace_back(n / g, 1);
    return factors;
  }
  factors.emplace_back(n, 1);
  return factors;
}
int64 minMaskCounter[1 << 16];
vector<int64> keyNumbers;
int getMinMask(int64 a) {
  int mask = 0;
  int64 nX = X;
  for (int i = 0; i < keyNumbers.size(); i++) {
    while (nX % keyNumbers[i] == 0) {
      nX /= keyNumbers[i];
      a /= keyNumbers[i];
    }
    if (a % keyNumbers[i] == 0) mask |= (1 << i);
  }
  return mask;
}
int getMaxMask(int64 a) {
  int mask = 0;
  int64 nY = Y;
  for (int i = 0; i < keyNumbers.size(); i++) {
    while (a % keyNumbers[i] == 0) {
      nY /= keyNumbers[i];
      a /= keyNumbers[i];
    }
    if (nY % keyNumbers[i] == 0) mask |= (1 << i);
  }
  return mask;
}
void setupMinMaskCounter() {
  for (int i = 0; i < n; i++) {
    if (a[i] % X != 0) continue;
    minMaskCounter[getMinMask(a[i])]++;
  }
  for (int i = 0; i < 16; i++) {
    for (int mask = 0; mask < (1 << 16); mask++) {
      if ((mask >> i) & 1) continue;
      minMaskCounter[mask | (1 << i)] += minMaskCounter[mask];
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> X >> Y;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (Y % X != 0) {
    cout << 0 << endl;
    return 0;
  } else if (Y == 1) {
    cout << n * n << endl;
    return 0;
  }
  auto primeFactors = factorize(Y);
  for (auto& mapping : primeFactors) {
    int cntX = countFactors(X, mapping.first), cntY = mapping.second;
    if (cntX < cntY) {
      keyNumbers.push_back(mapping.first);
    }
  }
  setupMinMaskCounter();
  int64 ans = 0;
  for (int i = 0; i < n; i++) {
    if (Y % a[i] != 0) continue;
    int mask = ((1 << 16) - 1) ^ getMaxMask(a[i]);
    ans += minMaskCounter[mask];
  }
  cout << ans << endl;
  return 0;
}
