#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() temp = [0] * 26 for char in word: temp[ord(char) - 97] = h[ord(char) - 97] print (max(temp) * len(word))