import java.util.*; public class ProblemA { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] arr = new int[26]; for(int i = 0 ; i < 26 ; i++){ arr[i] = sc.nextInt(); } sc.nextLine(); String str = sc.nextLine(); sc.close(); int maxHeight = 0; for(char c : str.toCharArray()){ maxHeight = Math.max(maxHeight, arr[c - 'a']); } System.out.println(maxHeight * str.length()); } }