#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
void chkmin(T &x, T y) {
  x = x > y ? y : x;
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= f;
}
const int N = 1 << 18;
int tot, mn[N], mx[N];
long long a[N], b[N], c[N], p[N];
const int P[10] = {2, 3, 5, 7, 11, 13, 19, 61, 2333, 24251};
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long mul(long long x, long long y, long long p) {
  long long ret = x * y - (long long)((long double)x * y / p + 0.5) * p;
  return ret < 0 ? ret + p : ret;
}
long long Pow(long long x, long long y, long long p) {
  long long ret = 1;
  for (; y; y >>= 1, x = mul(x, x, p))
    if (y & 1) ret = mul(ret, x, p);
  return ret;
}
bool check(int b, long long p) {
  if (b == p) return true;
  if (Pow(b, p - 1, p) != 1) return false;
  long long k = p - 1;
  while (k) {
    k >>= 1;
    long long t = Pow(b, k, p);
    if (mul(t, t, p) == 1 && t != 1 && t != p - 1) return false;
  }
  return true;
}
bool mr(long long p) {
  if (p == 1) return true;
  for (int i = 0; i < 10; i++)
    if (P[i] < p && !check(P[i], p)) return false;
  return true;
}
long long calc(long long n) {
  long long i = 0, k = 2, x, y, c = 1 + rand() % (n - 1);
  x = y = 1 + rand() % (n - 1);
  while (true) {
    x = (mul(x, x, n) + c) % n;
    long long d = gcd((y - x + n) % n, n);
    if (d > 1 && d < n) return d;
    if (x == y) return n;
    if (++i == k) y = x, k <<= 1;
  }
}
void pollard(long long n) {
  if (n == 1) return;
  if (mr(n)) return p[tot++] = n, void();
  long long m = n;
  while (n == m) m = calc(n);
  pollard(m), pollard(n / m);
}
void fwt(long long *a, int n, int fl) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0, r = i << 1; j < n; j += r)
      for (int k = 0; k < i; k++) a[j + k] += fl * a[i + j + k];
}
int main() {
  srand(20030324);
  int n;
  long long X, Y;
  read(n), read(X), read(Y);
  if (Y % X != 0) return cout << "0\n", 0;
  pollard(Y);
  sort(p, p + tot);
  tot = unique(p, p + tot) - p;
  int s = 0;
  for (int i = 0; i < tot; i++) {
    for (long long x = X; x % p[i] == 0; x /= p[i]) ++mn[i];
    for (long long x = Y; x % p[i] == 0; x /= p[i]) ++mx[i];
    if (mx[i] != mn[i]) s |= 1 << i;
  }
  int msk = 1 << tot;
  for (int i = 1; i <= n; i++) {
    long long x;
    read(x);
    int s1 = 0, s2 = 0;
    long long tx = x;
    for (int j = 0; j < tot; j++) {
      int sum = 0;
      while (x % p[j] == 0) x /= p[j], sum++;
      s1 |= (sum != mn[j]) << j, s2 |= (sum != mx[j]) << j;
    }
    if (tx % X == 0) a[s1]++;
    if (Y % tx == 0) b[s2]++;
  }
  fwt(a, msk, 1), fwt(b, msk, 1);
  for (int i = 0; i < msk; i++) a[i] *= b[i];
  fwt(a, msk, -1);
  long long ans = 0;
  for (int i = 0; i < msk; i++)
    if ((i & s) == 0) ans += a[i];
  cout << ans << '\n';
  return 0;
}
