#include using namespace std; #define endl '\n' #define ff first #define ss second #define pb push_back #define mp make_pair typedef long long llong; typedef pair pii; void solve() { vector sz(26); for(int i = 0; i < 26; i++) cin >> sz[i]; string s; cin >> s; int max_h = 0; for(char c : s){ max_h = max(max_h, sz[c - 'a']); } int ans = max_h * s.size(); cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef LOCAL ifstream in("in"); cin.rdbuf(in.rdbuf()); #endif solve(); return 0; }