#include #include #include #include #include using namespace std; int h[27]; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ for(int i = 0; i < 26; i++) cin >> h[i]; string s; cin >> s; int len = s.length(); int maxht =-1; for(int i = 0; i < len; i++) { maxht = max(maxht,h[s[i]-'a']); } cout << maxht*len; return 0; }