#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include #include using namespace std; using namespace atcoder; using mint=modint1000000007; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; vector A(n); rep(i,n) cin>>A[i]; string s; cin>>s; mint ans=1; map dp; rep(i,n){ mint tmp=ans; ans=(A[i]+1)*ans-A[i]*dp[s[i]]; dp[s[i]]=A[i]*tmp-(A[i]-1)*dp[s[i]]; } ans-=1; cout<