/* * Code Author: Akshay Miterani * DA-IICT */ import java.io.*; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; public class MainB { static double eps=(double)1e-6; static long mod=(int)1e9+7; public static void main(String args[]){ InputReader in = new InputReader(System.in); OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); //----------My Code---------- int h[]=new int[26]; for(int i=0;i<26;i++){ h[i]=in.nextInt(); } String s=in.nextLine(); int max=0; for(char p:s.toCharArray()){ max=Math.max(max, h[p-'a']); } System.out.println(s.length()*max); out.close(); //---------------The End------------------ } public static void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } static class Pair implements Comparable{ int x; int y; int i; Pair(int xx,int yy){ x=xx; y=yy; } @Override public int compareTo(Pair o) { return Integer.compare(this.x, o.x); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream inputstream) { reader = new BufferedReader(new InputStreamReader(inputstream)); tokenizer = null; } public String nextLine(){ String fullLine=null; while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { fullLine=reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } return fullLine; } return fullLine; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public long nextLong() { return Long.parseLong(next()); } public int nextInt() { return Integer.parseInt(next()); } } }