#include using namespace std; #define mid (lf + rg >> 1) #define right (left | 1) #define left (v << 1) #define pb push_back #define mp make_pair #define nd second #define st first typedef long long ll; typedef pair < int, int > pii; const ll linf = 1e18 + 9; const int inf = 1e9 + 9; const ll mod = 1e9 + 7; const int N = 5e5 + 9; int a[N]; string str; int main() { for (int i = 1; i <= 26; i++) scanf("%d", &a[i]); cin >> str; int res = 0; for (int i = 0; i < str.size(); i++) if (a[str[i] - 'a' + 1] > res) res = a[str[i] - 'a' + 1]; cout << res * str.size() << endl; return 0; }