#include using i64 = long long; constexpr int P = 1E9 + 7; inline void Inc(int &x, int y) { if ((x += y) >= P) x -= P; } int main() { std::cin.tie(nullptr) -> sync_with_stdio(false); int n; i64 m; std::cin >> n >> m; std::vector a(n); for (int i = 0; i < n; i++) { std::cin >> a[i]; a[i] = std::__gcd(a[i], m); } auto lcm = [&](int x, int y) { return 1ll * x * y / std::__gcd(x, y); }; int cnt = 0; __gnu_pbds::gp_hash_table mp; std::vector d; for (int i = 1; i * i <= m; i++) { if (m % i == 0) { d.push_back(i); if (i != m / i) d.push_back(m / i); } } std::sort(d.begin(), d.end()); for (auto x : d) { mp[x] = cnt++; } std::vector f(cnt); f[0] = 1; for (int i = 0; i < n; i++) { std::vector nf(cnt); for (auto x : d) { Inc(nf[mp[std::__gcd(1ll * m, 1ll * x * a[i])]], f[mp[x]]); Inc(nf[mp[x]], f[mp[x]]); } f = nf; } std::cout << f[cnt - 1] - (m == 1); return 0; }