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