#include using namespace std; typedef long long ll; typedef vector < int > vi; typedef vector < ll > vll; typedef vector < string > vs; #define sz(a) int((a).size()) #define sl(a) int((a).length()) #define pb push_back #define all(c) (c).begin(),(c).end() #define rall(c) (c).rbegin(),(c).rend() #define tr(con,it) for (__typeof((con).begin()) it = con.begin(); it != con.end(); it++) #define wl(x) (cout << (x) << endl) #define w(x) (cout << (x)) #define r(x) (cin >> (x)) #define FOR(i,a,b) for (int i = (a); i < (b); i++) #define ROF(i,a,b) for (int i = (b-1); i >= (a); i--) #define PP(x) tr(x,it) cout << it->first << " " << it->second << endl #define mp(x,y) make_pair((x),(y)) #define reset(x) memset((x),0,sizeof((x))) #define log(x) cout << #x << " = " << x << endl #define log2(x,y) cout << #x << " = " << x << " " << #y << " = " << y << endl #define log3(x,y,z) cout << #x << " = " << x << " " << #y << " = " << y << " " << #z << " = " << z << endl #define log4(x,y,z,t) cout << #x << " = " << x << " " << #y << " = " << y << " " << #z << " = " << z << " " << #t << " = " << t << endl #define MAXN 1000000005 #define MDL 1000000007 ll powmod(ll a,ll b) {ll res=1;a%=MDL;for(;b;b>>=1){if(b&1)res=res*a%MDL;a=a*a%MDL;}return res;} ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);} ll lcm(ll a,ll b) {return a*(b/gcd(a,b));} int main() { int T=1; //r(T); int x[26]; int temp=0; string s; reset(x); FOR(tt,0,T) { FOR(i,0,26) scanf("%d",&x[i]); r(s); FOR(i,0,sz(s)) temp=max(temp,x[s[i]-'a']); wl(temp*sz(s)); cerr << "case " << (tt+1) << " " << clock() << " ms" << endl; } return 0; }