#include <cstdio> #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <set> #include <map> #include <ctime> #include <cstring> #include <cassert> #include <bitset> #include <sstream> #include <queue> #define pb push_back #define mp make_pair #define fs first #define sc second #define sz(a) ((int) (a).size()) #define eprintf(...) fprintf(stderr, __VA_ARGS__) using namespace std; typedef long long int64; typedef long double ldb; const long double eps = 1e-9; const int inf = (1 << 30) - 1; const long long inf64 = ((long long)1 << 62) - 1; const long double pi = acos(-1); template <class T> T sqr (T x) {return x * x;} template <class T> T abs (T x) {return x < 0 ? -x : x;} int h[26]; string s; int main () { // ios_base::sync_with_stdio(0); // freopen("input.txt", "rt", stdin); // freopen("output.txt", "wt", stdout); for (int i = 0; i < 26; ++i) { cin >> h[i]; } cin >> s; int n = sz(s); int maxH = 0; for (int i = 0; i < n; ++i) { maxH = max(maxH, h[s[i] - 'a']); } cout << maxH * n << endl; return 0; }