#include #include #define rep(i,n) for(int i=0;i d; modinv(): n(2), d({0,1}) {} mint operator()(int i) { while (n <= i) d.push_back(-d[mint::mod()%n]*(mint::mod()/n)), ++n; return d[i]; } mint operator[](int i) const { return d[i];} } invs; struct modfact { int n; vector d; modfact(): n(2), d({1,1}) {} mint operator()(int i) { while (n <= i) d.push_back(d.back()*n), ++n; return d[i]; } mint operator[](int i) const { return d[i];} } facts; struct modfactinv { int n; vector d; modfactinv(): n(2), d({1,1}) {} mint operator()(int i) { while (n <= i) d.push_back(d.back()*invs(n)), ++n; return d[i]; } mint operator[](int i) const { return d[i];} } ifacts; mint comb(int n, int k) { if (n < k || k < 0) return 0; return facts(n)*ifacts(k)*ifacts(n-k); } int main(){ int n, k; cin >> n >> k; vector a(n); rep(i, n) cin >> a[i]; mint ans = 0; map ma; for(int r = 1; r <= k; r++){ int p = gcd(k, r); ma[p]++; } for(auto [p, t] : ma){ int q = k / p; queue> qu; qu.push(vector{1}); rep(i, n){ if(a[i] / q == 0) continue; vector f; for(int x = 0; x <= a[i] / q; x++){ f.push_back(ifacts(x)); } qu.push(f); } while(int(qu.size()) >= 2){ auto f = qu.front(); qu.pop(); auto g = qu.front(); qu.pop(); auto h = atcoder::convolution(f, g); qu.push(h); } auto res = qu.front(); if(int(res.size()) > p) ans += res[p] * facts(p) * t; } cout << (ans / k).val() << "\n"; return 0; }