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) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scan = new Scanner(System.in); int[] hts = new int[26]; int loopI; for(loopI =0 ; loopI < 26; ++loopI) { hts[loopI] = scan.nextInt(); //System.out.println(hts[loopI]); } String word = scan.next(); scan.close(); int width = word.length(),maxi = 0; for(loopI = 0; loopI < width; ++loopI) { char c = word.charAt(loopI); //System.out.println(c-92); if(hts[c-97]>maxi) { maxi = hts[c-97]; //System.out.println(maxi); } } System.out.println(maxi*width); } }