#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int sz[26];
	for (int i = 0; i < 26;++i)
		cin >> sz[i];
	char s[16];
	int res = 0;
	while (scanf("%s", s)==1) {
		int mx = 0;
		int len = strlen(s);
		for (int i = 0; s[i]; ++i)
			mx = max(mx, sz[s[i] - 'a']);
		res += mx*len;
	}
	cout << res << endl;
	return 0;
}