#include <bits/stdc++.h>
std::mt19937_64 rd(time(0) + (size_t) new char);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long deb = 12243;
namespace fact {
long long mul(long long a, long long b, long long mod) {
  long long t = a * b - (long long)((long double)a * b / mod + 0.5) * mod;
  return t + (t >> 63 & mod);
}
long long pow(long long a, long long b, long long mod, long long res = 1) {
  for (; b; b >>= 1, a = mul(a, a, mod))
    if (b & 1) res = mul(res, a, mod);
  return res;
}
const int pri[] = {2, 3, 5, 7, 19260817, 998244353, 1004535809};
const int TL = 7;
bool ispri(int x) {
  if (x < 2) return false;
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
bool MR(long long x) {
  if (x <= 100) return ispri(x);
  for (int i = 0; i < TL; ++i) {
    if (x == pri[i]) return true;
    long long b = pri[i] % x, t = pow(b, x - 1, x);
    if (t != 1) return false;
    long long now = x - 1;
    while (~now & 1) {
      t = pow(b, now >>= 1, x);
      if (t == x - 1) break;
      if (t != 1) return false;
    }
  }
  return true;
}
long long pollard(long long x) {
  long long x1 = rd() % (x - 1) + 1, x2 = x1;
  long long C = rd() % (x - 1) + 1, mx = 1;
  int stp = 0, lst = 1;
  while (true) {
    x2 = mul(x2, x2, x);
    x2 += C - x, x2 += x2 >> 63 & x;
    if (x1 == x2) return x;
    long long t = mul((x2 - x1 + x) % x, mx, x);
    if (t) mx = t;
    if ((stp & 127) == 0) {
      t = gcd(mx, x);
      if (t != x && t != 1) return t;
    }
    if (++stp == lst) x1 = x2, lst <<= 1;
  }
  return 12243;
}
std::map<long long, int> hav;
void _factor(long long x, int c = 1) {
  if (x == 1) return;
  if (MR(x)) return (void)(hav[x] += c);
  long long t;
  while ((t = pollard(x)) == x)
    ;
  int tc = 0;
  while (x % t == 0) x /= t, ++tc;
  _factor(x, c);
  _factor(t, tc * c);
}
std::vector<std::pair<long long, int> > factor(long long x) {
  hav.clear();
  _factor(x);
  std::vector<std::pair<long long, int> > res;
  for (auto t : hav) res.push_back(t);
  return res;
}
std::vector<std::pair<long long, int> > factorhint(
    long long x, std::vector<std::pair<long long, int> > y) {
  std::vector<std::pair<long long, int> > res;
  for (auto t : y) {
    int tc = 0;
    while (x % t.first == 0) x /= t.first, ++tc;
    res.emplace_back(t.first, tc);
  }
  res.emplace_back(deb, x > 1);
  return res;
}
}  // namespace fact
long long X, Y;
int n;
const int MAXN = 16;
int f[1 << MAXN], g[1 << MAXN];
int main() {
  std::ios_base::sync_with_stdio(false), std::cin.tie(0);
  std::cin >> n >> X >> Y;
  if (Y % X != 0) return std::cout << 0 << std::endl, 0;
  std::vector<std::pair<long long, int> > _y = fact::factor(Y), y = _y;
  y.emplace_back(deb, 0);
  std::vector<std::pair<long long, int> > x = fact::factorhint(X, _y);
  const int m = y.size();
  int mk = 0;
  for (int i = 1; i <= n; ++i) {
    long long T;
    std::cin >> T;
    std::vector<std::pair<long long, int> > t = fact::factorhint(T, _y);
    int s1 = 0, s2 = 0, k = 0;
    for (int j = 0; j != m; ++j) {
      if (y[j] < t[j]) s1 = -1;
      if (x[j] > t[j]) s2 = -1;
      if (x[j] != y[j]) {
        if (y[j] > t[j]) s1 |= 1 << k;
        if (x[j] < t[j]) s2 |= 1 << k;
        ++k;
      }
    }
    mk = std::max(k, mk);
    if (s1 != -1) ++f[s1];
    if (s2 != -1) ++g[s2];
  }
  const int U = 1 << mk;
  long long ans = 0;
  for (int i = 0; i != U; ++i) {
    const int I = U - i - 1;
    int t = 0;
    for (int j = I;; j = j - 1 & I) {
      t += f[j];
      if (!j) break;
    }
    ans += (long long)g[i] * t;
  }
  std::cout << ans << std::endl;
  return 0;
}
