import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] height = new int[26]; for (int i = 0; i < height.length; i++) { height[i] = in.nextInt(); } String word = in.next(); int length = word.length(); int maxHeight = 0; for (int i = 0; i < word.length(); i++) { maxHeight = Math.max(maxHeight, height[word.charAt(i) - 97]); } System.out.println(maxHeight * length); in.close(); } }