import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) mod = 10**9 + 7 N = int(input()) A = li() S = input() S = [ord(s)-ord("a") for s in S] dp = [0 for i in range(N)] memo = [0 for i in range(26)] for i in range(N): dp[i] = A[i] for j in range(26): if j!=S[i]: dp[i] += A[i] * memo[j] else: dp[i] += memo[j] dp[i] %= mod dp[i] %= mod memo[S[i]] = dp[i] res = sum(memo) % mod print(res)