def alp_to_num(cha): num = ord(cha) - ord("a") return num N = int(input()) A = list(map(int, input().split())) mod = 10 ** 9 + 7 S = list(input()) S = list(map(alp_to_num, S)) pre = [0] * 27 pre[26] = 1 psm = 1 for i in range(N): dp = [0] * 27 sm = 0 dp[S[i]] += (psm - pre[S[i]]) * A[i] for c in range(27): dp[c] += pre[c] sm += dp[c] dp[c] %= mod sm %= mod dp, pre = pre, dp sm, psm = psm, sm print(sum(pre[:26])% mod)