#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; typedef __int128_t lll; const ll INF=1ll<<62; struct R{ ll x, y; R(ll x, ll y):x(x), y(y){} R(ll x):x(x), y(1ll){} bool operator==(const R a) const{ return x*a.y==y*a.x; } bool operator<(const R a) const{ return x*a.y v){ int m=v.size(); if(m==0) return 1; int sum=0; for(auto a:v) sum+=a; if(x=INF) return INF; ret=ret1; } return ret; }else if(m==2 && v[0]==1 && v[1]==1){ lll ret=(lll)(x/2)*((x+1)/2); if(ret>=INF) return INF; else return ret; }else if(m==2 && v[0]==1 && v[1]==2){ ll l=2, r=x; auto calc=[&](ll a){ lll ret=(lll)(x-a)*a; if(ret>=INF) return INF; ret*=(a-1); ret/=2; if(ret>=INF) return INF; else return (ll)ret; }; while(r-l>2){ ll d=(r-l)/3; ll b=calc(l+d); if(b>=INF) return INF; ll c=calc(r-d); if(c>=INF) return INF; if(b>=c) r-=d; else l+=d; } ll ret=0; for(ll i=l; i<=r; i++){ ret=max(ret, calc(i)); } return ret; }else if(m==3 && v[0]==1 && v[1]==1 && v[2]==1){ lll a=x/3, b=x/3, c=x/3; if(x%3>=1) b++; if(x%3==2) c++; if(a*b>=INF || a*b*c>=INF) return INF; else return a*b*c; } ll ret=1; using Pr=pair; vector c(m); priority_queue que; for(int i=0; i=INF) return INF; ret=ret1; c[k]++; que.push({R(v[k]+c[k]+1, c[k]+1), k}); } return ret; } int main() { ll x[26]; for(int i=0; i<26; i++) cin>>x[i]; string t; cin>>t; vector v[26]; int cnt=1; for(int i=1; iINF/a){ ans=INF; }else{ ans*=a; } } if(ans>=INF) cout<<"hel"<