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) { Scanner in = new Scanner(System.in); int n = 26; int res = 0, count = 0, big = 0; int h[] = new int[n]; for(int h_i=0; h_i < n; h_i++){ h[h_i] = in.nextInt(); } String word = in.next(); int large[] = new int[word.length()]; char c[] = word.toCharArray(); char alpha[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; for(int i = 0; i < c.length; i++) { if(c[i] == alpha[i]) { count++; large[i] = h[i]; } } for(int i = 0; i < large.length; i++) { if(large[i] > big) { big = large[i]; } } res = (big*count); System.out.println(res); } }