//Header #include using namespace std; // Global declarations typedef long long int ll; typedef vector vi; typedef vector vc; typedef pair pi; typedef pair pll; typedef vector vpi; typedef vector vpll; typedef vector vll; const int mod = 1e9 + 7; const int INF = 1 << 29; const double eps = 1e-14; // Macros #define mp make_pair #define el putchar('\n') #define sp putchar(' ') #define Fill(a,val) memset(a,val,sizeof a) #define all(a) a.begin(),a.end() #ifndef ONLINE_JUDGE #define tr(a, it) for (decltype(a.begin()) it = a.begin(); it != a.end(); ++it) #else #define tr(a, it) for (typeof(a.begin()) it = a.begin(); it != a.end(); ++it) #endif #define in(n) scanf("%d",&n); #define inl(n) scanf("%lld",&n); #define out(n) printf("%d",n); #define outl(n) printf("%lld",n); int main(){ int h[26]; for (int i = 0; i < 26; ++i) in(h[i]); string a; cin >> a; int n = a.length(); int mx = 0; for (int i = 0; i < n; ++i){ mx = max(mx, h[a[i] - 'a']); } cout << mx*n; el; return 0; }