#include using namespace std; using ll = long long; int main () { int N; cin >> N; ll num[200010]; for (int i = 0; i < N; i ++) { cin >> num[i]; } string s; cin >> s; int id[26]; ll dp[26]; for (int i = 0; i < 26; i ++) { id[i] = -1; dp[i] = 1; } ll m = 1e9 + 7; ll ans = num[0]; for (int i = 0; i < N; i ++) { int n = s[i] - 'a'; for (int j = 0; j < 26; j ++) { if (j != n && id[j] > id[n]) { dp[n] += (dp[j] * num[id[j]]) % m; dp[n] %= m; } } id[n] = i; ans += (dp[n] * num[i]) % m; ans %= m; } cout << ans << endl; }