#include #include #define rep(i,b) for(int i=0;i=0;i--) #define rep1(i,b) for(int i=1;i using mpq = priority_queue, greater>; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (b ll sumv(const vector&a){ll res(0);for(auto&&x:a)res+=x;return res;} bool yn(bool a) { if(a) {cout << "Yes" << endl; return 1;} else {cout << "No" << endl; return 0;}} #define dame { cout << "No" << endl; return 0;} #define dame1 { cout << -1 << endl; return 0;} #define test(x) cout << "test" << x << endl; #define deb(x,y) cout << x << " " << y << endl; #define out cout << ans << endl; #define outv fore(yans , ans) cout << yans << endl; #define show(x) cerr<<#x<<" = "<; using pil = pair; using pli = pair; using pii = pair; using tp = tuple; using vi = vector; using vl = vector; using vs = vector; using vb = vector; using vpii = vector; using vpli = vector; using vpll = vector; using vpil = vector; using vvi = vector>; using vvl = vector>; using vvs = vector>; using vvb = vector>; using vvpii = vector>; using vvpli = vector>; using vvpll = vector; using vvpil = vector; using mint = modint998244353; using vm = vector; using vvm = vector>; vector dx={1,0,-1,0,1,1,-1,-1},dy={0,1,0,-1,1,-1,1,-1}; ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;} ll lcm(ll a, ll b) { return a/gcd(a,b)*b;} const double eps = 1e-10; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; int main(){ int n; cin>>n; ll s; cin>>s; vl a(n); rep(i,n) cin>>a[i]; vpll dp1,dp2; dp1.pb({0,1}); dp2.pb({0,1}); int m = n/2; rep(i,m){ vpll tmp; swap(tmp , dp1); int l=0; rep(j,sz(tmp)){ ll nxt = a[i]; pll y = tmp[j]; unordered_map mp; if (y.fi + nxt > s) break; while(y.fi + nxt <= s){ if (mp.count(y.fi + nxt)){ int k = mp[y.fi + nxt]; dp1[k].se += y.se; }else{ mp[y.fi + nxt] = l++; // dp1.pb({y.fi + nxt , y.se}); dp1.pb({y.fi + nxt , 0}); dp1[l-1].se += y.se; } nxt *= a[i]; } } sort(rng(dp1)); } repx(i,m,n){ vpll tmp; swap(tmp , dp2); int l=0; rep(j,sz(tmp)){ ll nxt = a[i]; pll y = tmp[j]; unordered_map mp; if (y.fi + nxt > s) break; while(y.fi + nxt <= s){ if (mp.count(y.fi + nxt)){ int k = mp[y.fi + nxt]; dp2[k].se += y.se; }else{ mp[y.fi + nxt] = l++; dp2.pb({y.fi + nxt , 0}); dp2[l-1].se += y.se; } nxt *= a[i]; } } sort(rng(dp2)); } ll ans=0; int l = sz(dp2); fenwick_tree ft(l); rep(i,l) ft.add(i , dp2[i].se); //deb(dp2[i].fi , dp2[i].se);} rep(i , sz(dp1)){ pll p = make_pair(s - dp1[i].fi+1 , -1); int k = upper_bound(rng(dp2) , p) - dp2.begin(); ans += ft.sum(0 , k); } out; return 0; }