import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] height = new int[26]; for (int i = 0; i < 26; i++) { height[i] = sc.nextInt(); } sc.nextLine(); String s = sc.nextLine(); int maxHeight = 1; for (int i = 0; i < s.length(); i++) { int index = s.charAt(i) - 'a'; if (height[index] > maxHeight) { maxHeight = height[index]; } } System.out.println(maxHeight * s.length()); } }