#include <bits/stdc++.h>
using namespace std;
class Record {
 public:
  long long factor;
  int cntx, cnty;
  Record(long long p, int x, int y) : factor(p), cntx(x), cnty(y) {}
  Record() {}
};
long long solve();
void get_factors_of_x_and_y();
int count_factor(long long num, long long p);
bool miller_rabin(long long x);
bool check(long long a, long long x);
void find_factor(long long x);
long long pollard_rho(long long x, long long a);
long long gcd(long long a, long long b);
long long sp_power(long long x, long long n, long long mod);
long long sp_multiply(long long a, long long b, long long mod);
const int MAX = 2e5 + 5, MAXF = 100, MAXL = (1 << 16) + 5;
long long a[MAX], X, Y;
long long factors[MAXF], fsize;
long long facnt_x[MAXF], facnt_y[MAXF];
vector<Record> bucket;
int dp[MAXL];
int n;
int main() {
  srand(time(NULL));
  while (scanf("%d %lld %lld", &n, &X, &Y) != EOF) {
    bucket.clear();
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
    }
    long long res = solve();
    printf("%lld\n", res);
  }
  return 0;
}
long long solve() {
  if (Y % X != 0) return 0;
  get_factors_of_x_and_y();
  for (int k = 1; k <= fsize; k++) {
    if (facnt_x[k] < facnt_y[k]) {
      bucket.push_back(Record(factors[k], facnt_x[k], facnt_y[k]));
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] % X != 0) continue;
    int limit = 0;
    for (int k = 0; k < bucket.size(); k++) {
      int cnti = count_factor(a[i], bucket[k].factor);
      if (cnti > bucket[k].cntx) {
        limit |= (1 << k);
      }
    }
    dp[limit]++;
  }
  int m = bucket.size();
  for (int i = 0; i < m; i++)
    for (int limit = 0; limit < (1 << m); limit++) {
      if ((limit >> i) & 1) {
        dp[limit] += dp[limit ^ (1 << i)];
      }
    }
  long long res = 0;
  for (int j = 1; j <= n; j++) {
    if (Y % a[j] != 0) continue;
    int limit = 0;
    for (int k = 0; k < bucket.size(); k++) {
      int cntj = count_factor(a[j], bucket[k].factor);
      if (cntj < bucket[k].cnty) {
        limit |= (1 << k);
      }
    }
    int sup = limit ^ ((1 << bucket.size()) - 1);
    res += dp[sup];
  }
  return res;
}
void get_factors_of_x_and_y() {
  fsize = 0;
  find_factor(Y);
  sort(factors + 1, factors + 1 + fsize);
  fsize = unique(factors + 1, factors + 1 + fsize) - (factors + 1);
  for (int i = 1; i <= fsize; i++) {
    facnt_y[i] = count_factor(Y, factors[i]);
    facnt_x[i] = count_factor(X, factors[i]);
  }
}
int count_factor(long long num, long long p) {
  int cnt = 0;
  while (num % p == 0) {
    cnt++;
    num /= p;
  }
  return cnt;
}
bool miller_rabin(long long x) {
  if (x == 1) return false;
  if (x == 2) return true;
  if (x % 2 == 0) return false;
  int T = 20;
  for (int i = 0; i < T; i++) {
    long long a = (rand() % (x - 1)) + 1;
    if (!check(a, x)) return false;
  }
  return true;
}
bool check(long long a, long long n) {
  long long d = n - 1;
  while (d % 2 == 0) d /= 2;
  long long t = sp_power(a, d, n);
  while (d != n - 1 && t != 1 && t != n - 1) {
    t = sp_multiply(t, t, n);
    d *= 2;
  }
  return (t == n - 1 || d % 2 == 1);
}
void find_factor(long long x) {
  if (miller_rabin(x)) {
    factors[++fsize] = x;
    return;
  }
  long long p = x;
  long long a = (rand() % (x - 1)) + 1;
  while (p >= x) {
    p = pollard_rho(p, a);
    a--;
  }
  find_factor(p);
  find_factor(x / p);
}
long long pollard_rho(long long x, long long a) {
  long long i = 1, k = 2;
  long long t = rand() % x;
  long long y = t;
  while (true) {
    i++;
    t = (sp_multiply(t, t, x) + a) % x;
    long long d = gcd(y - t, x);
    if (d > 1 && d < x) return d;
    if (y == t) return x;
    if (i == k) {
      y = t;
      k *= 2;
    }
  }
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long sp_power(long long a, long long b, long long mod) {
  long long res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      b--;
      res = sp_multiply(res, a, mod);
    } else {
      b /= 2;
      a = sp_multiply(a, a, mod);
    }
  }
  return res;
}
long long sp_multiply(long long a, long long b, long long mod) {
  long long res = 0;
  while (b > 0) {
    if (b % 2 == 1) {
      b--;
      res = (res + a) % mod;
    } else {
      b /= 2;
      a = (2 * a) % mod;
    }
  }
  return res;
}
