from bisect import bisect_left def ch(s): return ord(s) - ord('a') N = int(input()) memo = [[] for _ in range(26)] A = list(map(int,input().split())) mod = 10 ** 9 + 7 S = list(map(ch,list(input()))) dp = [0 for _ in range(N)] for i in range(N): if memo[S[i]] == []: dp[i] = 1 memo[S[i]].append(i) for i in range(N): for k in range(26): if memo[k] == []: pass else: index = bisect_left(memo[k],i+1) if index == len(memo[k]): continue nx = memo[k][index] if S[i] == k: dp[nx] += dp[i] else: dp[nx] += dp[i] * A[i] dp[nx] %= mod ans = 0 for i in range(N): ans += dp[i] * A[i] ans %= mod print(ans)