#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

const int N = 1e5+6;
const int M = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie();
	int arr[26];	for(int i=0;i<26;i++)	cin>>arr[i];
	string s;	cin>>s;
	int mx = 0;
	for(int i=0;i<s.length();i++){
		mx = max(mx,arr[s[i]-'a']);
	}
	int len = s.length();
	cout<<len*mx;

}