import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static int maxim; private static int[] height = new int[26]; private static String word; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); for ( int i = 0 ; i < 26 ; i ++ ) { height[i] = scanner.nextInt(); } word = scanner.next(); for ( int i = 0 ; i < word.length() ; i ++ ) { int index = Character.getNumericValue(word.charAt(i)) - Character.getNumericValue('a'); if ( height[index] > maxim ) { maxim = height[index]; } } int solution = maxim * word.length(); System.out.println(solution); } }