#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, lim = 1000000, M = (1 << 15) + 5;
template <typename T>
void read(T &x) {
  bool neg = false;
  unsigned char c = getchar();
  for (; (c ^ 48) > 9; c = getchar())
    if (c == '-') neg = true;
  for (x = 0; (c ^ 48) < 10; c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
  if (neg) x = -x;
}
int n, mc, md, k, f[M];
long long x, y, z, a[N], c[N], d[N], p[20], ans;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
int main() {
  int full;
  read(n);
  read(x);
  read(y);
  if (y % x) return puts("0"), 0;
  ;
  z = y / x;
  for (int i = 0, i_end = n; i < i_end; ++i) read(a[i]);
  for (int i = 0, i_end = n; i < i_end; ++i)
    if (a[i] % x == 0) c[mc++] = a[i] / x;
  for (int i = 0, i_end = n; i < i_end; ++i)
    if (y % a[i] == 0) d[md++] = y / a[i];
  for (int i = 2; i < lim && z != 1; ++i)
    if (z % i == 0) {
      p[k++] = i;
      while (z % i == 0) z /= i;
    }
  if (z != 1) {
    long long pp = sqrt(z) + 0.5;
    if (pp * pp == z) p[k++] = pp;
    for (int i = 0; i < mc && z != 1; ++i) {
      long long tmp = gcd(c[i], z);
      if (tmp != 1 && tmp != z) p[k++] = tmp, p[k++] = z / tmp, z = 1;
    }
    for (int i = 0; i < md && z != 1; ++i) {
      long long tmp = gcd(d[i], z);
      if (tmp != 1 && tmp != z) p[k++] = tmp, p[k++] = z / tmp, z = 1;
    }
    if (z != 1) p[k++] = z;
  }
  for (int i = 0, i_end = mc; i < i_end; ++i) {
    int t = 0;
    for (int j = 0, j_end = k; j < j_end; ++j)
      if (c[i] % p[j] == 0) t ^= 1 << j;
    ++f[t];
  }
  full = (1 << k) - 1;
  for (int i = 0, i_end = md; i < i_end; ++i) {
    int t = full;
    for (int j = 0, j_end = k; j < j_end; ++j)
      if (d[i] % p[j] == 0) t ^= 1 << j;
    for (int j = t; j; j = (j - 1) & t) ans += f[j];
    ans += f[0];
  }
  printf("%lld\n", ans);
  return 0;
}
