arr = list(map(int, input().split()))
s = input()
b = list(ord(x) - 97 for x in s)
x = []
for i in range(len(s)):
    x.append(arr[b[i]])
print(max(x) * len(s) * 1)

835d6f0b017bf98002ac4054785428dcc346cb48
<mask token>

<mask token>
for i in range(len(s)):
    x.append(arr[b[i]])
print(max(x) * len(s) * 1)

arr = list(map(int, input().split()))
s = input()
b = list(ord(x) - 97 for x in s)
x = []
for i in range(len(s)):
    x.append(arr[b[i]])
print(max(x) * len(s) * 1)
