/*
*/
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>  
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-10
#define M_PI 3.141592653589793
#define bs 1000000007;
#define bsize 512

const int N = 123031;

using namespace std;

int h[N];
int qh;

int main(){
	//freopen("beavers.in","r",stdin);
	//freopen("beavers.out","w",stdout);
	//freopen("F:/in.txt","r",stdin);
	//freopen("F:/output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	for (int i = 'a'; i <= 'z'; i++)
	{
		cin >> h[i];
	}

	int qh = 0;
	string st;
	cin >> st;
	for (int i = 0; i < st.size(); i++)
	{
		qh = max(qh, h[st[i]]);
	}
	cout << qh*st.size() << endl;

	cin.get(); cin.get();
	return 0;
}