N = int(input()) A = list(map(int,input().split())) S = input() last = [-1] * 26 P = 10 ** 9 + 7 dp = [0] * N _sum = [0] * (N+1) dp[0] = A[0] c = ord(S[0]) - ord('a') last[c] = 0 _sum[1] = A[0] for i in range(1,N): c = ord(S[i]) - ord('a') if last[c] == -1: dp[i] = (_sum[i]+1) * A[i] % P else: dp[i] = (_sum[i] - dp[last[c]] + 1) * A[i] % P _sum[i+1] = (_sum[i] + dp[i]) % P last[c] = i ans = 0 for i in range(N): ans = (ans + dp[i]) % P print(ans)