#include <bits/stdc++.h>
using namespace std;
const int S = 10;
long long mult_mod(long long a, long long b, long long c) {
  a %= c, b %= c;
  long long ret = 0, tmp = a;
  while (b) {
    if (b & 1) {
      ret += tmp;
      if (ret > c) ret -= c;
    }
    tmp <<= 1;
    if (tmp > c) tmp -= c;
    b >>= 1;
  }
  return ret;
}
long long pow_mod(long long a, long long n, long long mod) {
  long long ret = 1, temp = a % mod;
  while (n) {
    if (n & 1) ret = mult_mod(ret, temp, mod);
    temp = mult_mod(temp, temp, mod);
    n >>= 1;
  }
  return ret;
}
bool check(long long a, long long n, long long x, long long t) {
  long long ret = pow_mod(a, x, n);
  long long last = ret;
  for (int i = 1; i <= t; i++) {
    ret = mult_mod(ret, ret, n);
    if (ret == 1 && last != 1 && last != n - 1) return true;
    last = ret;
  }
  if (ret != 1)
    return true;
  else
    return false;
}
bool Miller_Rabin(long long n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if ((n & 1) == 0) return false;
  long long x = n - 1;
  long long t = 0;
  while ((x & 1) == 0) {
    x >>= 1;
    t++;
  }
  srand(time(NULL));
  for (int i = 0; i < S; i++) {
    long long a = rand() % (n - 1) + 1;
    if (check(a, n, x, t)) return false;
  }
  return true;
}
long long factor[100];
set<long long> vis;
long long temp[20];
int tol;
long long gcd(long long a, long long b) {
  long long t;
  while (b) {
    t = a;
    a = b;
    b = t % b;
  }
  if (a >= 0)
    return a;
  else
    return -a;
}
long long pollard_rho(long long x, long long c) {
  long long i = 1, k = 2;
  srand(time(NULL));
  long long x0 = rand() % (x - 1) + 1;
  long long y = x0;
  while (1) {
    i++;
    x0 = (mult_mod(x0, x0, x) + c) % x;
    long long d = gcd(y - x0, x);
    if (d != 1 && d != x) return d;
    if (y == x0) return x;
    if (i == k) {
      y = x0;
      k += k;
    }
  }
}
void findfac(long long n, int k) {
  if (n == 1) return;
  if (Miller_Rabin(n)) {
    factor[tol++] = n;
    return;
  }
  long long p = n;
  int c = k;
  while (p >= n) p = pollard_rho(p, c--);
  findfac(p, k);
  findfac(n / p, k);
}
void FWT(int a[], int n, int flag) {
  for (int d = 1; d < n; d <<= 1)
    for (int i = 0; i < n; i += (d << 1))
      for (int j = 0; j < d; j++) a[i + j] += a[i + j + d] * flag;
}
void FWT_And(int *A, int len) {
  if (len == 1) return;
  int len2 = len >> 1;
  FWT_And(A, len2);
  FWT_And(A + len2, len2);
  for (int i = 0; i < len2; i++) A[i] += A[i + len2];
}
void IFWT_And(int *A, int len) {
  if (len == 1) return;
  int len2 = len >> 1;
  for (int i = 0; i < len2; i++) A[i] -= A[i + len2];
  IFWT_And(A, len2);
  IFWT_And(A + len2, len2);
}
long long a[200005], ta[200005];
int have[200005][16];
int havex[16], havey[16];
int mask[1 << 16];
int main() {
  int n;
  long long x, y;
  scanf("%d%lld%lld", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    ta[i] = a[i];
  }
  if (y % x != 0) {
    puts("0");
    return 0;
  }
  tol = 0;
  findfac(y, 107);
  int tcnt = 0;
  for (int i = 0; i < tol; i++) {
    if (factor[i] && !vis.count(factor[i])) {
      vis.insert(factor[i]);
      temp[tcnt++] = factor[i];
    }
  }
  tol = tcnt;
  for (int i = 0; i < tol; i++) factor[i] = temp[i];
  long long tx = x, ty = y;
  for (int i = 0; i < tol; i++) {
    while (ty % factor[i] == 0) {
      ty /= factor[i];
      havey[i]++;
    }
    while (tx % factor[i] == 0) {
      tx /= factor[i];
      havex[i]++;
    }
    for (int j = 0; j < n; j++) {
      if (y % a[j] == 0 || a[j] % x == 0)
        while (ta[j] % factor[i] == 0) {
          ta[j] /= factor[i];
          have[j][i]++;
        }
    }
  }
  for (int j = 0; j < n; j++) {
    if (y % a[j] == 0) {
      int temp = a[j], id = 0;
      for (int k = 0; k < tol; k++) {
        if (have[j][k] == havey[k]) id |= (1 << k);
      }
      mask[id]++;
    }
  }
  FWT_And(mask, 1 << tol);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] % x == 0) {
      int need = 0;
      for (int j = 0; j < tol; j++) {
        if (have[i][j] > havex[j] && havex[j] < havey[j]) need |= (1 << j);
      }
      ans += mask[need];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
