#include #include #include #include #include #include #include #include using namespace std; #define N 26 int h[N]; string word; int main() { //freopen ("file.in", "r", stdin); //freopen ("file.out", "w", stdout); for (int i = 0; i < N; i++) cin >> h[i]; cin >> word; int hmax = 0; for (int i = 0; i < word.length(); i++) hmax = max(hmax, h[word[i] - 'a']); cout << hmax*word.length() << endl; return 0; }