#include <bits/stdc++.h>
using ll = long long;
const int C = 1000001, D = 18, F = 200001;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  ll c;
  while (b > 0) c = a % b, a = b, b = c;
  return a;
}
inline ll mul(ll a, ll b, ll M) {
  if (b == 0) return 0;
  ll c = 0;
  while (b > 0) {
    if (b % 2 == 1) c = (c + a) % M;
    b /= 2;
    a = (a + a) % M;
  }
  return c;
}
inline ll pow(ll a, ll b, ll M) {
  if (b == 0) return 1;
  ll c = 1;
  while (b > 0) {
    if (b % 2 == 1) c = mul(a, c, M);
    b /= 2;
    a = mul(a, a, M);
  }
  return c;
}
template <class NUMBER>
int find_divs(int* pr, NUMBER a, NUMBER dv[], int s[]) {
  int ln = 0;
  while (a > 1) {
    if (ln == 0 || pr[a] != dv[ln - 1])
      dv[ln] = pr[a], s[ln] = 1, ln++;
    else
      s[ln - 1]++;
    a /= pr[a];
  }
  return ln;
}
bool determine_prime(ll enigma) {
  ll cur_power, para_toth = enigma - 1;
  int amount = 0, i;
  for (para_toth = enigma - 1, amount = 0; (para_toth & 1) == 0;
       amount++, para_toth >>= 1)
    ;
  for (int test : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}) {
    if (enigma == test) return true;
    cur_power = pow(test, para_toth, enigma);
    if (cur_power == 1 || cur_power == enigma - 1) continue;
    ;
    for (i = 0; i < amount; i++) {
      cur_power = mul(cur_power, cur_power, enigma);
      if (enigma - 1 == cur_power) break;
    }
    if (i == amount) return false;
  }
  return true;
}
void supfactor(int* pr, int v) {
  int i, j;
  pr[1] = 1;
  for (i = 2; i * i < v; i++) {
    if (pr[i] == 0) {
      for (j = i; j < v; j += i) {
        if (pr[j] == 0) pr[j] = i;
      }
    }
  }
  for (; i < v; i++)
    if (pr[i] == 0) pr[i] = i;
}
ll rho_fun(ll x, ll mod, ll c) { return (mul(x, x, mod) + c) % mod; }
ll find_factor_rho(ll number, ll c = 1) {
  ll g = 1, fun1_x = 1, fun2_x = 1;
  while (g == 1) {
    fun1_x = rho_fun(fun1_x, number, c);
    fun2_x = rho_fun(rho_fun(fun2_x, number, c), number, c);
    g = gcd(std::max((fun2_x - fun1_x), (fun1_x - fun2_x)), number);
  }
  return g;
}
ll tmp_dv2[D];
int tmp_s2[D];
int merge(ll tmp_dv[], int tmp_s[], int tmp_ln, ll dv[], int s[], int old_ln) {
  int tmp_ln2 = old_ln, i = 0, j = 0, k = 0;
  for (i = 0; i < old_ln; i++) tmp_dv2[i] = dv[i];
  for (i = 0; i < old_ln; i++) tmp_s2[i] = s[i];
  for (i = 0, j = 0; i < tmp_ln || j < tmp_ln2;) {
    if (j >= tmp_ln2 || (i < tmp_ln && tmp_dv[i] < tmp_dv2[j]))
      dv[k] = tmp_dv[i], s[k] = tmp_s[i], i++;
    else if (i >= tmp_ln || tmp_dv[i] > tmp_dv2[j])
      dv[k] = tmp_dv2[j], s[k] = tmp_s2[j], j++;
    else
      dv[k] = tmp_dv[i], s[k] = tmp_s[i] + tmp_s2[j], i++, j++;
    k++;
  }
  return k;
}
ll tmp_FIFO[D], tmp_dv[D];
int tmp_s[D];
int dissolve(ll number, ll dv[], int s[], int* pr = nullptr, int ln_p = 0) {
  if (number == 1) return 0;
  int ln = 0, iF, jF, is_prime, tmp_ln;
  ll v, divisor, some_c = 1;
  tmp_FIFO[0] = number;
  for (iF = 0, jF = 1; iF < jF; iF++) {
    v = tmp_FIFO[iF];
    if (v < ln_p) {
      tmp_ln = find_divs<ll>(pr, v, tmp_dv, tmp_s);
      ln = merge(tmp_dv, tmp_s, tmp_ln, dv, s, ln);
      continue;
    }
    is_prime = determine_prime(v);
    tmp_dv[0] = v, tmp_s[0] = 1;
    if (is_prime)
      ln = merge(tmp_dv, tmp_s, 1, dv, s, ln);
    else {
      divisor = v, some_c = 1;
      while (divisor == v) divisor = find_factor_rho(v, some_c++);
      tmp_FIFO[jF] = divisor;
      tmp_FIFO[jF + 1] = v / divisor;
      jF += 2;
    }
  }
  return ln;
}
int create_all(int bit1[], int ln1, int bit2[], int ln2, int pw[], int res[],
               int piece = 0) {
  int i, j, cur_val = 0;
  for (i = 0; i < ln1; i++) cur_val += pw[bit1[i]];
  i = 0;
  while (true) {
    res[i] = cur_val;
    i++;
    for (j = 0; j < ln2; j++) {
      if ((pw[bit2[j]] & cur_val) == 0) {
        cur_val |= pw[bit2[j]];
        break;
      }
      cur_val ^= pw[bit2[j]];
    }
    if (j == ln2) break;
  }
  return i;
}
int primes[C], s[D], x_s[D], gcd_amount[F], real_amount_lcm[F],
    real_amount_gcd[F];
int leftmost[F], sgn[F], pw[D], bitte[F], allez1[F], allez2[F];
ll a[F], dv[D];
int main() {
  int n, i, j, ij, ln, systematic_ln, cnt = 0, pos_gcd, pos_lcm;
  ll x, neo_x, y, v, grande_finale = 0;
  scanf("%d %lld %lld", &n, &x, &y);
  for (i = 0; i < n; i++) scanf("%lld", &a[i]);
  if (y % x != 0) {
    printf("0\n");
    return 0;
  }
  supfactor(primes, C);
  ln = dissolve(y, dv, s, primes, C);
  neo_x = x;
  for (i = 0; i < ln; i++) {
    while (neo_x % dv[i] == 0) x_s[i]++, neo_x /= dv[i];
  }
  pw[0] = 1;
  for (i = 1; i <= ln; i++) pw[i] = pw[i - 1] * 2;
  for (i = 0; i < n; i++) {
    pos_gcd = 0, pos_lcm = 0;
    v = a[i];
    for (j = 0; j < ln; j++) {
      cnt = 0;
      while (v % dv[j] == 0) {
        v /= dv[j];
        cnt++;
      }
      if (cnt > x_s[j]) pos_gcd += pw[j];
      if (cnt < s[j]) pos_lcm += pw[j];
    }
    if (a[i] % x == 0) real_amount_gcd[pos_gcd] += 1;
    if (y % a[i] == 0) real_amount_lcm[pos_lcm] += 1;
  }
  leftmost[0] = -1;
  sgn[0] = -1;
  for (i = 1; i < pw[ln]; i++) {
    leftmost[i] = leftmost[i / 2] + 1;
    sgn[i] = sgn[i ^ pw[leftmost[i]]] * (-1);
  }
  int post_ln1, post_ln2, gcd_val;
  for (i = 0; i < pw[ln]; i++) {
    ij = 0;
    for (j = 0; j < ln; j++) {
      if ((pw[j] & i) > 0) bitte[ij] = j, ij++;
    }
    post_ln1 =
        create_all(bitte + ij / 2, ij / 2 + ij % 2, bitte, ij / 2, pw, allez1);
    post_ln2 = create_all(bitte, ij / 2, bitte + ij / 2, ij / 2 + ij % 2, pw,
                          allez2, 1);
    for (j = 0; j < post_ln1 - 1; j++) {
      gcd_amount[i] += gcd_amount[allez1[j]] * sgn[i ^ allez1[j]];
    }
    for (j = 0; j < post_ln2; j++) {
      gcd_amount[i] += real_amount_gcd[allez2[j]];
    }
  }
  for (i = 0; i < pw[ln]; i++) {
    gcd_val = 0;
    for (j = 0; j < ln; j++) {
      if ((i & pw[j]) == 0 || s[j] == x_s[j]) gcd_val |= pw[j];
    }
    grande_finale += 1ll * real_amount_lcm[i] * gcd_amount[gcd_val];
  }
  printf("%lld\n", grande_finale);
  return 0;
}
