#include #define left nadnlassad #define right asdaslknd #define y1 kjdajasjdsas #define nxt accepted #define prev why_would_you_call_when_you_are_high #define pb push_back #define mp make_pair #define mt make_tuple #define f first #define s second #define ll long long #define ld long double #define ull unsigned ll #define _hash pair #define pii pair #define uint unsigned int #define puu pair #define sqr(x) ((x) * 1LL * (x)) #define vec vector #define sz(v) int(v.size()) #define all(v) v.begin(), v.end() #define endl "\n" #define _bits(x) __builtin_popcountll(x) using namespace std; void rf() { #define fname "sparse" #ifdef SONY freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #else //freopen(fname".in", "r", stdin); //freopen(fname".out", "w", stdout); #endif //SONY } const int nx[8] = {2, -2, -2, 2, 1, 1, -1, -1}; const int ny[8] = {1, 1, -1, -1, 2, -2, -2, 2}; const int Nx[4] = {0, 0, -1, 1}; const int Ny[4] = {1, -1, 0, 0}; const ll LINF = (ll) 5e18; const int INF = 1e9 + 7; const int N = 6e5 + 1; const int MAXN = 1e6 + 50; const double EPS = 1e-9, PI = 3.14159265359; int h[26]; string s; int main() { srand(time(0)); //ios_base::sync_with_stdio(0), cin.tie(0); rf(); for (int i = 0; i < 26; i++) cin >> h[i]; cin >> s; int ans = h[s[0] - 'a']; for (auto i : s) { ans = max(ans, h[i - 'a']); } cout << ans * 1LL * sz(s); return 0; }