#include <bits/stdc++.h>
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void sub(long long &a, long long b) {
  a -= b;
  if (a < 0) a += 1000000009;
}
inline void add(long long &a, long long b) {
  a += b;
  if (a >= 1000000009) a -= 1000000009;
}
template <typename T>
inline T const &MAX(T const &a, T const &b) {
  return a > b ? a : b;
}
template <typename T>
inline T const &MIN(T const &a, T const &b) {
  return a < b ? a : b;
}
inline long long qp(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 1000000009;
    a = a * a % 1000000009, b >>= 1;
  }
  return ans;
}
inline long long qp(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c, b >>= 1;
  }
  return ans;
}
inline long long qm(long long a, long long b, long long c) {
  long long ans = 0;
  while (b) {
    if (b & 1) ans = (ans + a) % c;
    a = (a + a) % c;
    b >>= 1;
  }
  return ans % c;
}
inline long long qpow(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = qm(ans, a, c) % c;
    a = qm(a, a, c) % c;
    b >>= 1;
  }
  return ans;
}
using namespace std;
const unsigned long long ba = 233;
const double eps = 1e-10;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 200000 + 10, maxn = 100000 + 10, inf = 0x3f3f3f3f;
int cnt;
long long f[110];
bool check(long long a, long long n, long long x, long long sum) {
  long long judge = qpow(a, x, n);
  if (judge == n - 1 || judge == 1) return 1;
  while (sum--) {
    judge = qm(judge, judge, n);
    if (judge == n - 1) return 1;
  }
  return 0;
}
bool miller(long long n) {
  if (n < 2) return 0;
  if (n == 2) return 1;
  if ((n & 1) == 0) return 0;
  long long x = n - 1, sum = 0;
  while (x % 2 == 0) x >>= 1, sum++;
  for (long long i = 1; i <= 20; i++) {
    long long a = rand() % (n - 1) + 1;
    if (!check(a, n, x, sum)) return 0;
  }
  return 1;
}
long long pollard(long long n, long long c) {
  long long x, y, d, i = 1, k = 2;
  x = rand() % n;
  y = x;
  while (1) {
    i++;
    x = (qm(x, x, n) + c) % n;
    d = gcd(y - x, n);
    if (d < 0) d = -d;
    if (d > 1 && d < n) return d;
    if (y == x) return n;
    if (i == k) y = x, k <<= 1;
  }
}
void Find(long long n) {
  if (n == 1) return;
  if (miller(n)) {
    f[cnt++] = n;
    return;
  }
  long long p = n;
  while (p >= n) p = pollard(p, rand() % (n - 1) + 1);
  Find(n / p);
  Find(p);
}
long long a[N], b[N], c[N];
int cal(long long x, long long y) {
  int ans = 0;
  while (x % y == 0) ans++, x /= y;
  return ans;
}
void fwt_and(long long *a, int n, int dft) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = j; k < j + i; k++) {
        if (dft == 1)
          a[k] = a[k] + a[i + k];
        else
          a[k] = a[k] - a[i + k];
      }
}
int main() {
  int n;
  long long x, y;
  scanf("%d%lld%lld", &n, &x, &y);
  if (y % x) return 0 * puts("0");
  Find(y);
  sort(f, f + cnt);
  cnt = unique(f, f + cnt) - f;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    int p1 = 0, p2 = 0;
    for (int j = 0; j < cnt; j++)
      if (cal(x, f[j]) != cal(y, f[j])) {
        p1 += (1 << j) * (cal(a[i], f[j]) > cal(x, f[j]));
        p2 += (1 << j) * (cal(a[i], f[j]) < cal(y, f[j]));
      }
    if (a[i] % x == 0) b[p1]++;
    if (y % a[i] == 0) c[p2]++;
  }
  fwt_and(b, (1 << cnt), 1);
  fwt_and(c, (1 << cnt), 1);
  for (int i = 0; i < (1 << cnt); i++) b[i] = b[i] * c[i];
  fwt_and(b, (1 << cnt), -1);
  printf("%lld\n", b[0]);
  return 0;
}
