#include <bits/stdc++.h>

using namespace std;

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h[26];
    for(int i = 0; i < 26; i++)
        cin >> h[i];
    string s;
    cin >> s;
    int mx = 0;
    for(auto c: s)
        mx = max(mx, h[c - 'a']);
    cout << s.size() * mx << "\n";
    return 0;
}