import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; public class B { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int[] h = new int[26]; for(int i = 0;i < 26;i++) h[i] = sc.nextInt(); String s = sc.next(); int ans = 0, maxh = 0; for(int i = 0;i < s.length();i++) maxh = Math.max(maxh, h[s.charAt(i) - 'a']); out.println(s.length() * maxh); out.close(); } }