#include <bits/stdc++.h>
using namespace std;
const int maxN = 200011;
const int limit = 1000000;
const int maxBit = 20;
long long n, X, Y, i, bts, max_conf;
long long a[maxN];
vector<pair<long long, long long> > divs, divs2, act;
vector<long long> to_check;
vector<long long> A, B;
long long data[1 << maxBit];
long long ans;
void give(long long x) {
  cout << x;
  exit(0);
}
long long gcd(long long x, long long y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    x %= y;
    swap(x, y);
  }
  return x;
}
void fact(long long x) {
  long long i, cnt, aux;
  if (Y % X) give(0);
  for (i = 2; i * i <= x && i <= limit; i++) {
    if (x % i) continue;
    cnt = 0;
    while (x % i == 0) {
      cnt++;
      x /= i;
    }
    divs.push_back(make_pair(i, cnt));
  }
  if (x == 1) return;
  aux = llround(sqrt(x));
  if (aux * aux == x) {
    divs.push_back(make_pair(aux, 2));
    return;
  }
  to_check.push_back(X);
  to_check.push_back(Y);
  for (auto e : to_check) {
    aux = gcd(e, x);
    if (aux == 1 || aux == x) continue;
    divs.push_back(make_pair(aux, 1));
    divs.push_back(make_pair(x / aux, 1));
    return;
  }
  divs.push_back(make_pair(x, 1));
}
void fact_smart(long long x, vector<pair<long long, long long> >& to) {
  long long cnt, aux;
  to.clear();
  aux = x;
  for (auto e : divs) {
    cnt = 0;
    while (aux % e.first == 0) {
      cnt++;
      aux /= e.first;
    }
    to.push_back(make_pair(e.first, cnt));
  }
}
void add_elem(long long x) {
  long long i, j, cnt, aux;
  long long conf, pos = 0;
  aux = x;
  conf = pos = 0;
  for (auto e : divs2) {
    cnt = 0;
    while (aux % e.first == 0) {
      cnt++;
      aux /= e.first;
    }
    if (cnt != e.second && e.second != divs[pos].second) conf |= 1 << pos;
    pos++;
  }
  if (x % X == 0) A.push_back(conf);
  aux = x;
  conf = pos = 0;
  for (auto e : divs) {
    cnt = 0;
    while (aux % e.first == 0) {
      cnt++;
      aux /= e.first;
    }
    if (cnt != e.second && e.second != divs2[pos].second) conf |= 1 << pos;
    pos++;
  }
  if (Y % x == 0) B.push_back(conf);
}
void solve() {
  long long i, j;
  bts = divs.size();
  max_conf = 1 << bts;
  for (auto e : A) data[e]++;
  for (i = 0; i < bts; i++)
    for (j = 0; j < max_conf; j++)
      if ((j >> i) & 1) data[j] += data[j ^ (1 << i)];
  for (auto e : B) ans += data[(max_conf - 1) ^ e];
  give(ans);
}
int main() {
  cin >> n >> X >> Y;
  for (i = 1; i <= n; i++) cin >> a[i], to_check.push_back(a[i]);
  fact(Y);
  fact_smart(X, divs2);
  for (i = 1; i <= n; i++) add_elem(a[i]);
  solve();
  return 0;
}
