import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### m = 26 mod = 10 ** 9 + 7 n = ni() a = [1] + na() s = [ord(x)-97 for x in input()] f = [[-1 for i in range(n+1)] for j in range(m)] for i in range(n-1, -1, -1): for j in range(m): f[j][i] = f[j][i+1] f[s[i]][i] = i s = [-1] + s # print(f) dp = [0] * (n + 1) dp[0] = 1 for i in range(n): for j in range(m): if f[j][i] != -1: if s[i] != j: dp[f[j][i] + 1] += dp[i] * a[i] % mod else: dp[f[j][i] + 1] += dp[i] dp[f[j][i] + 1] %= mod # print(dp) ans = 0 for i in range(1, n + 1): ans += dp[i] * a[i] % mod ans %= mod print(ans)