#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, M = 21;
int lim;
long long prim[30], idx[30], v[N], low[30];
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void FMT(long long *A, int tag) {
  for (int i = 0; i < lim; i++)
    for (int s = (1 << lim) - 1; s >= 0; s--)
      if (!((s >> i) & 1)) A[s] += tag * A[s | (1 << i)];
}
long long F[(1 << M) + 2], G[(1 << M) + 2];
int main() {
  int n, cnt = 0;
  long long x, y;
  scanf("%d%lld%lld", &n, &x, &y);
  if (y % x) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) scanf("%lld", &v[i]);
  long long now = y;
  for (int i = 2; 1ll * i * i * i <= now; i++) {
    if (now % i) continue;
    prim[++cnt] = i;
    while (now % i == 0) now /= i, idx[cnt]++;
  }
  for (int i = 1; i <= n; i++) {
    long long cur = v[i];
    for (int j = 1; j <= cnt; j++)
      while (cur % prim[j] == 0) cur /= prim[j];
    long long GCD = gcd(now, cur), tr;
    if (GCD == 1) continue;
    tr = sqrt(GCD);
    if (tr * tr == GCD) {
      prim[++cnt] = tr;
      while (now % tr == 0) now /= tr, idx[cnt]++;
      continue;
    }
    int flag = 1;
    for (int j = 1; j <= n; j++) {
      tr = gcd(GCD, v[j]);
      if (tr > 1 && tr < GCD) {
        prim[++cnt] = tr;
        while (now % tr == 0) now /= tr, idx[cnt]++;
        tr = GCD / tr, flag = 0;
        prim[++cnt] = tr;
        while (now % tr == 0) now /= tr, idx[cnt]++;
        break;
      }
    }
    if (flag) {
      prim[++cnt] = GCD;
      while (now % GCD == 0) now /= GCD, idx[cnt]++;
    }
  }
  now = x, lim = cnt;
  for (int i = 1; i <= cnt; i++) {
    if (now % prim[i]) continue;
    while (now % prim[i] == 0) now /= prim[i], low[i]++;
  }
  for (int i = 1; i <= n; i++) {
    int sta1 = 0, sta2 = 0;
    now = v[i];
    for (int j = 1; j <= cnt; j++) {
      if (low[j] == idx[j]) continue;
      int cur = 0;
      while (now % prim[j] == 0) now /= prim[j], cur++;
      if (cur > low[j]) sta1 |= (1 << (j - 1));
      if (cur < idx[j]) sta2 |= (1 << (j - 1));
    }
    if (v[i] % x == 0) F[sta1]++;
    if (y % v[i] == 0) G[sta2]++;
  }
  FMT(F, 1), FMT(G, 1);
  for (int i = 0; i < (1 << lim); i++) F[i] = F[i] * G[i];
  FMT(F, -1);
  printf("%lld\n", F[0]);
  return 0;
}
