#include #include #include #include #include #include #include int main(){ int max=0,i,j; int *h = malloc(sizeof(int) * 26); for(int h_i = 0; h_i < 26; h_i++){ scanf("%d",&h[h_i]); } char* s = (char *)malloc(512000 * sizeof(char)); scanf("%s",s); for(i=0;s[i]!='\0';i++) { if(h[s[i]-97]>max) max=h[s[i]-97]; } printf("%d",max*i); return 0; }