#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}
template <typename T, typename... U>
inline void read(T& x, U&... y) {
  read(x), read(y...);
}
template <typename T>
inline bool checkMax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
template <typename T>
inline bool checkMin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
const int N = 2e5 + 10;
inline long long get_rand(long long n) {
  return (((unsigned long long)rand() + 100000007) * rand()) % n + 1;
}
inline long long gcd(long long x, long long y) {
  return !y ? x : gcd(y, x % y);
}
inline void add(long long& x, long long y, long long mod) { x = (x + y) % mod; }
inline void mul(long long& x, long long y, long long mod) {
  x = ((x * y - (long long)(((long double)x * y + 0.5) / mod) * mod) % mod +
       mod) %
      mod;
}
inline long long qpow(long long v, long long p, long long mod) {
  long long res = 1;
  for (; p; p >>= 1, mul(v, v, mod)) {
    if (p & 1) {
      mul(res, v, mod);
    }
  }
  return res;
}
inline bool miller_rabin(long long p) {
  if (p == 2 || p == 3 || p == 7 || p == 61 || p == 24251) {
    return true;
  }
  if (p == 1 || !(p & 1) || !(p % 3) || !(p % 7) || !(p % 61) || !(p % 24251) ||
      p == 46856248255981) {
    return false;
  }
  long long d = p - 1;
  int s = 0;
  for (; !(d & 1); ++s, d >>= 1)
    ;
  for (register int i = 0; i < 5; ++i) {
    long long x = get_rand(p - 2);
    long long last = qpow(x, d, p), y = 0;
    for (register int j = 0; j < s; ++j, last = y) {
      mul(y = last, last, p);
      if (y == 1 && (last ^ 1) && (last ^ p - 1)) {
        return false;
      }
    }
    if (y ^ 1) {
      return false;
    }
  }
  return true;
}
const int M = (1 << 7) - 1;
inline long long g(long long x, long long c, long long mod) {
  mul(x, x, mod), add(x, c, mod);
  return x;
}
inline long long pollard_rho(long long p, int c) {
  if (!(p % 2)) {
    return 2;
  }
  if (!(p % 3)) {
    return 3;
  }
  long long x = 0, y = x, t = 1, q = 1, a = get_rand(p - 1);
  for (int k = 2;; k <<= 1, y = x, q = 1) {
    for (int i = 1; i <= k; ++i) {
      x = g(x, c, p);
      mul(q, abs(x - y), p);
      if (!(i & M)) {
        t = gcd(q, p);
        if (t > 1) {
          break;
        }
      }
    }
    if (t > 1 || (t = gcd(q, p)) > 1) {
      break;
    }
  }
  if (t == p) {
    t = 1;
    for (; t == 1; t = gcd(abs((x = g(x, c, p)) - y), p))
      ;
  }
  return t;
}
vector<long long> e;
inline void solve(long long p, int c) {
  if (p == 1) {
    return;
  }
  if (miller_rabin(p)) {
    e.push_back(p);
    return;
  }
  long long v = p;
  for (; v == p; v = pollard_rho(p, c--))
    ;
  solve(v, c);
  solve(p / v, c);
}
int n, minv[N], maxv[N], c[N];
long long first, second, a[N];
inline void fwt(int* c, int S) {
  for (register int i = 1; i < S; i <<= 1) {
    for (register int j = 0; j < S; j += i << 1) {
      for (register int k = 0; k < i; ++k) {
        c[i + j + k] += c[j + k];
      }
    }
  }
}
int main() {
  read(n, first, second);
  for (register int i = 1; i <= n; ++i) {
    read(a[i]);
  }
  if (second % first) {
    return puts("0"), 0;
  }
  solve(second, 1000003);
  sort(e.begin(), e.end());
  e.erase(unique(e.begin(), e.end()), e.end());
  int all = 1 << (int)e.size();
  long long x1 = first, y1 = second;
  for (register int i = 0; i < e.size(); ++i) {
    for (; x1 % e[i] == 0; ++minv[i], x1 /= e[i])
      ;
  }
  for (register int i = 0; i < e.size(); ++i) {
    for (; y1 % e[i] == 0; ++maxv[i], y1 /= e[i])
      ;
  }
  for (register int i = 1; i <= n; ++i) {
    if (a[i] % first) {
      continue;
    }
    long long v = a[i];
    int S = 0;
    for (register int j = 0; j < e.size(); ++j) {
      int res = 0;
      for (; v % e[j] == 0; ++res, v /= e[j])
        ;
      if (res > minv[j]) {
        S |= 1 << j;
      }
    }
    ++c[S];
  }
  fwt(c, all);
  long long ans = 0;
  for (register int i = 1; i <= n; ++i) {
    if (second % a[i]) {
      continue;
    }
    long long v = a[i];
    int S = 0;
    for (register int j = 0; j < e.size(); ++j) {
      int res = 0;
      for (; v % e[j] == 0; ++res, v /= e[j])
        ;
      if (res < maxv[j] && (minv[j] ^ maxv[j])) {
        S |= 1 << j;
      }
    }
    ans += c[(all - 1) ^ S];
  }
  printf("%lld\n", ans);
  return 0;
}
