//#include #include #include #include #include #include #include #include #include #include //#include //#include //using namespace __gnu_pbds; using namespace std; //using namespace atcoder; #ifdef LOCAL #define show(x) cerr << #x" = " << (x) << "\n" #else #define show(x) 0 #endif #define pb push_back #define pp pop_back #define mp make_pair #define fst first #define snd second #define FOR(var, from, to) for(int var = from; var < int(to); ++var) #define all(x) x.begin(), x.end() #define rev(x) x.rbegin(), x.rend() #define sz(x) int(x.size()) #define vec(x) vector #define INF 2000000000 //using mint = modint998244353; typedef long long ll; typedef pair pii; typedef pair pll; //typedef tree,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // use unique second element of pair to work as multiset //typedef tree,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset; const ll mod = 1234567891, mod2 = 998244353; template ostream &operator<<(ostream &os, pair p){os << "(" << p.fst << "," << p.snd << ")"; return os;} template istream &operator>>(istream &is, pair &p){is >> p.fst >> p.snd; return is;} template istream &operator>>(istream &is, vector &v){FOR(i, 0, v.size()) is >> v[i]; return is;} template ostream &operator<<(ostream &os, vector v){for(T x : v) os << x << " "; return os;} template ostream &operator<<(ostream &os, set s){for(T x : s) os << x << " "; return os;} template ostream &operator<<(ostream &os, multiset s){for(T x : s) os << x << " "; return os;} template ostream &operator<<(ostream &os, map m){for(auto x : m) os << x << " "; return os;} //ostream &operator<<(ostream &os, ordered_set s){for(int x : s) os << x << " "; return os;} //ostream &operator<<(ostream &os, ordered_multiset s){for(pii x : s) os << x.fst << " "; return os;} ll mod_pow(ll a, ll b, ll m){ ll sol = 1; while(b){ if(b&1){ sol = (sol*a)%m; b--; }else{ a = (a*a)%m; b/=2; } } return sol;} ll rem(ll a, ll b){ ll res = a%b; return res < 0 ? res+b : res; } const int N = 3e5 + 9; struct base { double x, y; base() { x = y = 0; } base(double x, double y): x(x), y(y) { } }; inline base operator + (base a, base b) { return base(a.x + b.x, a.y + b.y); } inline base operator - (base a, base b) { return base(a.x - b.x, a.y - b.y); } inline base operator * (base a, base b) { return base(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); } inline base conj(base a) { return base(a.x, -a.y); } ll lim = 1; vector roots = {{0, 0}, {1, 0}}; vector rev = {0, 1}; const double PI = acosl(- 1.0); void ensure_base(ll p) { if(p <= lim) return; rev.resize(1 << p); for(ll i = 0; i < (1 << p); i++) rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (p - 1)); roots.resize(1 << p); while(lim < p) { double angle = 2 * PI / (1 << (lim + 1)); for(ll i = 1 << (lim - 1); i < (1 << lim); i++) { roots[i << 1] = roots[i]; double angle_i = angle * (2 * i + 1 - (1 << lim)); roots[(i << 1) + 1] = base(cos(angle_i), sin(angle_i)); } lim++; } } void fft(vector &a, ll n = -1) { if(n == -1) n = a.size(); assert((n & (n - 1)) == 0); ll zeros = __builtin_ctz(n); ensure_base(zeros); ll shift = lim - zeros; for(ll i = 0; i < n; i++) if(i < (rev[i] >> shift)) swap(a[i], a[rev[i] >> shift]); for(ll k = 1; k < n; k <<= 1) { for(ll i = 0; i < n; i += 2 * k) { for(ll j = 0; j < k; j++) { base z = a[i + j + k] * roots[j + k]; a[i + j + k] = a[i + j] - z; a[i + j] = a[i + j] + z; } } } } //eq = 0: 4 FFTs in total //eq = 1: 3 FFTs in total vector multiply(vector &a, vector &b, ll eq = 0) { ll need = a.size() + b.size() - 1; ll p = 0; while((1 << p) < need) p++; ensure_base(p); ll sz = 1 << p; vector A, B; if(sz > (ll)A.size()) A.resize(sz); for(ll i = 0; i < (ll)a.size(); i++) { ll x = (a[i] % mod + mod) % mod; A[i] = base(x & ((1 << 15) - 1), x >> 15); } fill(A.begin() + a.size(), A.begin() + sz, base{0, 0}); fft(A, sz); if(sz > (ll)B.size()) B.resize(sz); if(eq) copy(A.begin(), A.begin() + sz, B.begin()); else { for(ll i = 0; i < (ll)b.size(); i++) { ll x = (b[i] % mod + mod) % mod; B[i] = base(x & ((1 << 15) - 1), x >> 15); } fill(B.begin() + b.size(), B.begin() + sz, base{0, 0}); fft(B, sz); } double ratio = 0.25 / sz; base r2(0, - 1), r3(ratio, 0), r4(0, - ratio), r5(0, 1); for(ll i = 0; i <= (sz >> 1); i++) { ll j = (sz - i) & (sz - 1); base a1 = (A[i] + conj(A[j])), a2 = (A[i] - conj(A[j])) * r2; base b1 = (B[i] + conj(B[j])) * r3, b2 = (B[i] - conj(B[j])) * r4; if(i != j) { base c1 = (A[j] + conj(A[i])), c2 = (A[j] - conj(A[i])) * r2; base d1 = (B[j] + conj(B[i])) * r3, d2 = (B[j] - conj(B[i])) * r4; A[i] = c1 * d1 + c2 * d2 * r5; B[i] = c1 * d2 + c2 * d1; } A[j] = a1 * b1 + a2 * b2 * r5; B[j] = a1 * b2 + a2 * b1; } fft(A, sz); fft(B, sz); vector res(need); for(ll i = 0; i < need; i++) { long long aa = A[i].x + 0.5; long long bb = B[i].x + 0.5; long long cc = A[i].y + 0.5; res[i] = (aa + ((bb % mod) << 15) + ((cc % mod) << 30))%mod; } return res; } vector pow(vector& a, ll p) { vector res; res.emplace_back(1); while(p) { if(p & 1) res = multiply(res, a); a = multiply(a, a, 1); p >>= 1; } return res; } void test_case(){ ll n, m; cin >> n >> m; vec(int) v(n); cin >> v; queue q; for(int x : v){ vec(ll) cur(x+1); cur[0] = 1; cur[x] = 1; q.push(cur); } while(sz(q) > 1){ vec(ll) p1 = q.front(); q.pop(); vec(ll) p2 = q.front(); q.pop(); q.push(multiply(p1, p2)); } vec(ll) F = q.front(); cerr << "xd\n"; auto Si = [&](int r, vec(ll) v){ FOR(i, 0, sz(v)){ int who = 2*i + r; v[i] = who < sz(v) ? v[who] : 0LL; } while(!v.back()) v.pp(); return v; }; vec(ll) A{1}; while(m){ int r = m % 2; A = Si(r, multiply(A, F)); m /= 2; } cout << A[0] << "\n"; } int main(){ #ifndef LOCAL ios_base::sync_with_stdio(false); cin.tie(NULL); #endif int t = 1; FOR(i, 0, t) test_case(); return 0; }