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] hoka = [0] * N hoka[0] = 1 for i in range(1,N): c = ord(S[i]) - ord('a') if last[c] == -1: dp[i] = (_sum[i]+1) * A[i] % P hoka[i] = _sum[i]+1 else: dp[i] = (_sum[i] - _sum[last[c]+1] + hoka[last[c]] ) * A[i] % P hoka[i] = (_sum[i] - _sum[last[c]+1] + hoka[last[c]]) % 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)