#include using namespace std; #define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) typedef long long ll; ll arr[26]; int main(){ boost; ll h,N,i,j; string str; ll res; for(i = 0 ; i < 26 ; i++) cin >> arr[i]; cin >> str; ll _max = 0; for(i = 0 ; i < str.length() ; i++) _max = max(_max,arr[str[i]-'a']); cout << str.length()*_max << endl; }