#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


void Solve()
{
	vector<int> a(26);
	for(auto &x: a)
		cin >> x;
    string s;
    cin >> s;
    int highest=0;
    for(auto &x: s)
        {
        highest=max(a[x-'a'], highest);
    }
   printf("%d", highest*s.size());
}

int main()
{
	int t=1;
//	cin >> t;
	for(int tc=1; tc<=t; ++tc)
	{
		Solve();
	}
}