/* Success consists of going from failure to failure without loss of enthusiasm. - Winston Churchill */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define tr(x) cout << x << endl; #define tr2(x, y) cout << x << " " << y << endl; #define tr3(x, y, z) cout << x << " " << y << " " << z << endl; #define tr4(w, x, y, z) cout << w << " " << x << " " << y << " " << z << endl; #define tr6(a, b, w, x, y, z) cout << a << " " << b << " " << w << " " << x << " " << y << " " << z << endl; #define ll long long #define fastIO ios::sync_with_stdio(false); cin.tie(0); inline int in() { int x; scanf("%d", &x); return x; } inline long long inL() { long long x; scanf("%lld", &x); return x; } string toString(long long n) { stringstream ss; ss << n; return ss.str(); } long long toNumber(string s){ stringstream ss; long long n; ss << s; ss >> n; return n; } const int N = 1e5 + 9; int main(){ #ifdef __APPLE__ const clock_t begin_time = clock(); freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif map a; for (char c = 'a'; c <= 'z'; c++) { int x = in(); a[c] = x; } string s; cin >> s; ll area = s.length(); ll maxi = -1; for (char c : s) { maxi = max(a[c]*1LL, maxi); } cout << area * maxi << endl; #ifdef __APPLE__ cout << endl; cout << "Time : "; cout << float( clock () - begin_time ) / CLOCKS_PER_SEC << endl; #endif return 0; }