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