#include #include #include #include #include using namespace std; void Solve() { vector a(26); for(auto &x: a) cin >> x; string s; cin >> s; int highest=0; for(auto &x: s) { highest=max(a[x-'a'], highest); } printf("%d", highest*s.size()); } int main() { int t=1; // cin >> t; for(int tc=1; tc<=t; ++tc) { Solve(); } }