#include using namespace std; #include using namespace atcoder; using mint=modint1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n;cin>>n; vcv(n); rep(i,n)cin>>v[i]; sr s;cin>>s; vcdp(n+1,0); dp[0]=1; //vcdx(n+1,0); vclast(26,-1); rep(i,n){ auto&x=dp[i+1]; x=dp[i]*(v[i]+1); int t=last[s[i]-'a']; if(t!=-1)x-=(dp[t]-(dp[t]-dp[t-1])/v[t-1])*(v[i]); last[s[i]-'a']=i+1; } mint ans=dp[n]-1; cout<