#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n;
long long X, Y;
int f[1 << 20];
long long a[N];
vector<long long> pri;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
void add(long long f) {
  long long x = X, y = Y;
  int cx = 0, cy = 0;
  while (x % f == 0) cx++, x /= f;
  while (y % f == 0) cy++, y /= f;
  if (cx < cy) pri.push_back(f);
}
void split(long long num) {
  for (int i = 2; i <= 1000000; i++) {
    if (num % i == 0) {
      add(i);
      while (num % i == 0) {
        num /= i;
      }
    }
  }
  if (num == 1) return;
  long long x = sqrt(num);
  if (x * x == num) {
    add(x);
  } else {
    for (int i = 0; i < n; i++) {
      long long g = gcd(a[i], num);
      if (g > 1 && g < num) {
        add(g);
        add(num / g);
        return;
      }
    }
    add(num);
  }
}
int main() {
  scanf("%d%lld%lld", &n, &X, &Y);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  if (Y % X != 0) {
    puts("0");
    return 0;
  }
  split(Y);
  int tot = (int)pri.size();
  long long tmp = X;
  vector<int> pcnt(tot, 0);
  for (int i = 0; i < tot; i++) {
    pcnt[i] = 0;
    while (tmp % pri[i] == 0) {
      tmp /= pri[i];
      pcnt[i]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] % X != 0) continue;
    long long tmp = a[i];
    int mask = 0;
    for (int j = 0; j < tot; j++) {
      int cnt = 0;
      if (tmp % pri[j] == 0) {
        while (tmp % pri[j] == 0) {
          cnt++;
          tmp /= pri[j];
        }
      }
      if (cnt > pcnt[j]) {
        mask += (1 << j);
      }
    }
    f[mask]++;
  }
  for (int i = 0; i < tot; i++) {
    for (int mask = 0; mask < (1 << tot); mask++) {
      if (mask & (1 << i)) {
        f[mask] += f[mask ^ (1 << i)];
      }
    }
  }
  tmp = Y;
  for (int i = 0; i < tot; i++) {
    pcnt[i] = 0;
    while (tmp % pri[i] == 0) {
      tmp /= pri[i];
      pcnt[i]++;
    }
  }
  long long ret = 0;
  int full = (1 << tot) - 1;
  for (int i = 0; i < n; i++) {
    if (Y % a[i] != 0) continue;
    long long tmp = a[i];
    int mask = 0;
    for (int j = 0; j < tot; j++) {
      int cnt = 0;
      if (tmp % pri[j] == 0) {
        while (tmp % pri[j] == 0) {
          cnt++;
          tmp /= pri[j];
        }
      }
      if (cnt < pcnt[j]) {
        mask += (1 << j);
      }
    }
    ret += f[mask ^ full];
  }
  printf("%lld\n", ret);
  return 0;
}
