n = int(input()) A = list(map(int,input().split())) S = input() mod = 10**9+7 next = [[n]*26 for i in range(n+1)] for i in range(n)[::-1]: s = ord(S[i])-ord("a") for j in range(26): if j == s: next[i][j] = i else: next[i][j] = next[i+1][j] dp = [0]*(n+2) for i in range(26): if next[0][i] != n: dp[next[0][i]] += 1 ans = 0 for i,(a,s) in enumerate(zip(A,S)): s = ord(s)-ord("a") ans += dp[i]*a ans %= mod for j in range(26): if s == j: dp[next[i+1][j]] += dp[i] else: dp[next[i+1][j]] += dp[i]*a%mod dp[next[i+1][j]] %= mod print(ans)