#include using namespace std; int main() { auto heights = array{}; for (auto& x : heights) cin >> x; string s; cin >> s; auto max_height = 0; for (auto c : s) max_height = max(max_height, heights[c-'a']); cout << max_height * s.length() << endl; }