#include #define nl cout << "\n" #define pb(a) push_back(a) #define mp(a,b) make_pair(a,b) #define ll long long #define fi first #define se second #define fl(i,a,b) for(int i=a;i=b;--i) #define all(a) a.begin(),a.end() #define pii pair #define vi vector #define vll vector #define vb vector #define vpii vector > #define vpib vector > #define vvi vector > #define DEBUG(x) cout << "value of " << #x << " is " << x << "\n" #define DEBUG2(x,y) cout << "value of " << #x << " is " << x << "\tvalue of " << #y << " is " << y << "\n" #define DEBUG3(x,y,z) cout << "value of " << #x << " is " << x << "\tvalue of " << #y << " is " << y << "\tvalue of " << #z << " is " << z << "\n" #define c_false ios_base::sync_with_stdio(false); cin.tie(0) // apac macros section int tcase = 1 ; #define pcase cout << "Case #" << tcase++ << ": " const int mod = 1000000007; const ll lmod = 1000000000000000007 ; const int nmax = INT_MAX; const int nmin = INT_MIN; using namespace std; // long array 10^7 range //ll a[23456789] ; int main(){ c_false ; // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // std::cout << std::fixed << std::showpoint; // std::cout << std::setprecision(6); vi v(26) ; fl(i,0,26) cin >> v[i] ; string str ; cin >> str ; int n = str.size() ; int maxi = 0 ; fl(i,0,n){ maxi = max(maxi,v[str[i]-'a']) ; } cout << n*maxi ; return 0; }