#include <bits/stdc++.h>
using namespace std;
int n;
long long ans, X, Y, s[200010], w[30], t, A[131072], B[131072];
inline long long gcd(long long a, long long b) {
  for (long long c; b; a = b, b = c) c = a % b;
  return a;
}
int main() {
  scanf("%d%lld%lld", &n, &X, &Y);
  for (int i = 1; i <= n; ++i) scanf("%lld", s + i);
  if (Y % X) return 0 & puts("0");
  long long D = Y;
  for (int i = 2; D > 1 && i <= 1000000; ++i)
    if (D % i == 0)
      for (w[++t] = i; D % i == 0; D /= i)
        ;
  if (D > 1) {
    long long Q = sqrt(D);
    if (Q * Q == D)
      w[++t] = Q;
    else
      for (int i = 1; i <= n; ++i) {
        if ((Q = gcd(D, s[i])) > 1 && Q < D) {
          w[++t] = Q;
          w[++t] = D / Q;
          break;
        }
      }
    w[++t] = D;
  }
  int a[30] = {0}, b[30] = {0}, T;
  for (int i = 1; i <= t; ++i) {
    for (D = X; D % w[i] == 0; D /= w[i]) ++a[i];
    for (D = Y; D % w[i] == 0; D /= w[i]) ++b[i];
  }
  for (int i = 1; i <= n; ++i)
    if (Y % s[i] == 0) {
      int c[30] = {0}, k = 0;
      D = s[i];
      for (int j = 1; j <= t; ++j)
        if (D % w[j] == 0)
          for (; D % w[j] == 0; ++c[j]) D /= w[j];
      for (int j = 1; j <= t; ++j)
        if (c[j] == b[j]) k ^= (1 << j - 1);
      ++B[k];
    }
  int N = 1 << t;
  for (int i = 1; i <= N; i <<= 1)
    for (int j = i; j < N; ++j& i ? 0 : j |= i) B[j ^ i] += B[j];
  for (int i = 1; i <= n; ++i)
    if (s[i] % X == 0) {
      int c[30] = {0}, k = (1 << t) - 1;
      D = s[i];
      for (int j = 1; j <= t; ++j)
        if (D % w[j] == 0)
          for (; D % w[j] == 0; ++c[j]) D /= w[j];
      for (int j = 1; j <= t; ++j)
        if (c[j] == a[j] || a[j] == b[j]) k ^= (1 << j - 1);
      ans += B[k];
    }
  printf("%lld\n", ans);
}
