#include using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(x) begin(x), end(x) template using V = vector; #include using namespace atcoder; using mint = modint1000000007; ostream &operator<<(ostream &os, const mint &p) { return os << p.val(); } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; V A(N); rep(i, N) cin >> A[i]; string S; cin >> S; V B(N); rep(i, N) B[i] = S[i] - 'a'; V sig(26, 0); rep(i, N) { mint nx = A[i]; rep(k, 26) { if (k == B[i]) continue; nx += sig[k] * A[i]; } sig[B[i]] += nx; } mint ans = 0; rep(k, 26) ans += sig[k]; cout << ans.val() << '\n'; return 0; }