/*	Author: Ankit Sultana
 * * * * * * * * * * * * * * * * */
#include <iostream>
#define LL long long
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;
int height[1000];

int main() {
    ios_base::sync_with_stdio(false);
    for(int i = 'a'; i <= 'z'; i++)
        cin >> height[i];
    string s;
    cin >> s;
    int res = s.size(), h = 0;
    for(auto &c: s) {
        h = max(h, height[c]);
    }
    res *= h;
    cout << res << '\n';
    return 0;
}