#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T modMul(T a, T b, T m) {
  T x = 0, y = a % m;
  while (b > 0) {
    if (b % 2 == 1) x = (x + y) % m;
    y = (y * 2) % m;
    b /= 2;
  }
  return x % m;
}
template <typename T>
T pollard(T n) {
  int i = 0, k = 2, d;
  T x = 3, y = 3;
  while (true) {
    i++;
    x = (modMul(x, x, n) + n - 1) % n;
    d = gcd(abs(y - x), n);
    if (d != 1 && d != n) return d;
    if (i == k) y = x, k *= 2;
  }
}
template <typename T>
T modExp(T a, T b, T m) {
  if (b == 0) return (T)1;
  T c = modExp(a, b / 2, m);
  c = modMul(c, c, m);
  if (b % 2 != 0) c = modMul(c, a, m);
  return c;
}
bool miller(long long n) {
  const int pn = 9;
  const int p[] = {2, 3, 5, 7, 11, 13, 17, 19, 23};
  for (int i = 0; i < pn; i++)
    if (n % p[i] == 0) return n == p[i];
  if (n < p[pn - 1]) return false;
  long long s = 0, t = n - 1;
  while (~t & 1) t >>= 1, ++s;
  for (int i = 0; i < pn; ++i) {
    long long pt = modExp((long long)p[i], t, n);
    if (pt == 1) continue;
    bool ok = false;
    for (int j = 0; j < s && !ok; j++) {
      if (pt == n - 1) ok = true;
      pt = modMul(pt, pt, n);
    }
    if (!ok) return false;
  }
  return true;
}
long long arr[200009], mskcnt[1 << 16];
int main() {
  long long n, x, y;
  scanf("%lld %lld %lld", &n, &x, &y);
  vector<long long> div;
  int cnt_y[20], cnt_x[20];
  long long d = y;
  for (int i = 2; 1LL * i * i <= d && i <= 10000000; i++) {
    if (d % i == 0) {
      int cnt = 0;
      while (d % i == 0) {
        d /= i;
        cnt++;
      }
      cnt_y[div.size()] = cnt;
      div.push_back(i);
    }
  }
  if (d > 1) {
    if (miller(d)) {
      cnt_y[div.size()] = 1;
      div.push_back(d);
    } else {
      long long p = pollard(d);
      if (p * p == d) {
        cnt_y[div.size()] = 2;
        div.push_back(p);
      } else {
        cnt_y[div.size()] = 1;
        div.push_back(p);
        cnt_y[div.size()] = 1;
        div.push_back(d / p);
      }
    }
  }
  if (y % x != 0) {
    puts("0");
    return 0;
  }
  d = x;
  for (int idx = 0; idx < div.size(); idx++) {
    long long i = div[idx];
    int cnt = 0;
    while (d % i == 0) {
      d /= i;
      cnt++;
    }
    if (cnt == cnt_y[idx]) {
      swap(div.back(), div[idx]);
      swap(cnt_y[div.size() - 1], cnt_y[idx]);
      idx--;
      div.pop_back();
    } else
      cnt_x[idx] = cnt;
  }
  for (int i = 0; i < n; i++) scanf("%lld", &arr[i]);
  for (int i = 0; i < n; i++) {
    long long val = arr[i];
    if (val % x == 0) {
      int mask = 0;
      d = val;
      for (int idx = 0; idx < div.size(); idx++) {
        long long i = div[idx];
        int cnt = 0;
        while (d % i == 0) {
          d /= i;
          cnt++;
        }
        if (cnt > cnt_x[idx]) {
          mask |= (1 << idx);
        }
      }
      mskcnt[mask]++;
    }
  }
  for (int i = 0; i < div.size(); i++) {
    for (int mask = 0; mask < (1 << div.size()); mask++) {
      if (mask & (1 << i)) {
        mskcnt[mask] += mskcnt[mask ^ (1 << i)];
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long val = arr[i];
    if (y % val == 0) {
      int mask = 0;
      d = val;
      for (int idx = 0; idx < div.size(); idx++) {
        long long i = div[idx];
        int cnt = 0;
        while (d % i == 0) {
          d /= i;
          cnt++;
        }
        if (cnt < cnt_y[idx]) {
          mask |= (1 << idx);
        }
      }
      mask = (~mask) & ((1 << div.size()) - 1);
      ans += mskcnt[mask];
    }
  }
  printf("%lld\n", ans);
}
