#include using namespace std; #define mp make_pair #define pb push_back typedef long long ll; typedef pair pii; typedef vector vi; #define DEBUG 0 #define dout if(DEBUG) cout int h[26]; void solve(){ int mx = 0; for(int i = 0; i < 26; i++){ cin >> h[i]; } string s; cin >> s; int n = s.length(); for(int i = 0; i < n; i++){ mx = max(mx, h[s[i] - 'a']); } cout << mx * n; } int main() { #ifdef NASTYA assert(freopen("input.txt", "r", stdin)); assert(freopen("output.txt", "w", stdout)); #else //assert(freopen(file".in", "r", stdin)); assert(freopen(file".out", "w", stdout)); #endif int t = 1; while(t--) { solve(); } return 0; }