#include using namespace std; using ll = long long; std::vector> factor(unsigned long long x) { std::vector> ret; if (x % 2 == 0) { for (ret.push_back({2, 0}); x % 2 == 0; x /= 2) ret.back().second++; } for (long long p = 3; p * p <= x; p += 2) { if (x % p == 0) { for (ret.push_back({p, 0}); x % p == 0; x /= p) ret.back().second++; } } if (x != 1) ret.push_back({x, 1}); return ret; } const int md = (int)1e9 + 7; int N, K; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); cin >> N >> K; auto d = factor(K); vector> A(N); for(int i = 0; i < N; i++) { ll a; cin >> a; vector B(d.size()); for(int j = 0; j < d.size(); j++) { while(a % d[j].first == 0) { B[j] += 1; a /= d[j].first; } } A[i] = B; } map, int> dp; dp[vector(d.size())] = 1; for(int i = 0; i < N; i++) { map, int> ndp = dp; for(const auto&[ps, val]: dp) { auto ns = ps; for(int j = 0; j < d.size(); j++) { ns[j] += A[i][j]; ns[j] = min(ns[j], (int)d[j].second); } ndp[ns] += val; ndp[ns] %= md; } swap(dp, ndp); } vector s(d.size()); for(int i = 0; i < d.size(); i++) s[i] = d[i].second; int ans = dp[s]; if(K == 1) ans--; cout << ans << "\n"; }