#include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <set> #include <map> #include <string> #include <algorithm> using namespace std; int main() { int h[26]; for (int i = 0; i < 26;i++) { scanf("%d", &h[i]); } char word[30]; scanf("%s", word); int w = 0, hh = 0; for (int i = 0; word[i]; i++) { w++; hh = max(hh, h[word[i] - 'a']); } printf("%d\n", w*hh); return 0; }