import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Solution { public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] heights = new int[26]; for(int i = 0; i<26; i++){ heights[i] = sc.nextInt(); } String S = sc.next(); int width = S.length(); int height = 0; for(char c : S.toCharArray()){ int ind = c - 'a'; height = Math.max(height, heights[ind]); } System.out.println(width*height); } }