#undef LOCAL //#define LOCAL #ifndef LOCAL #define NDEBUG #endif #include #include #include #include #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; typedef int64_t ll; typedef uint64_t ull; #define sz(a) ((int) (a).size()) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define unq(a) (a).resize(unique(all(a)) - (a).begin()) #define rep(i, b) for (int (i) = 0; (i) < (b); ++(i)) #define repab(i, a, b) for (int (i) = (a); (i) < (b); ++(i)) #define rrep(i, b) for (int (i) = (b) - 1; (i) >= 0; --(i)) #define rrepab(i, a, b) for (int (i) = (b) - 1; (i) >= (a); --(i)) #define vi vector #define vl vector #define vii vector> #define vvi vector> #define vvii vector>> #define ms(a, p) memset((a), (p), sizeof(a)) #define pb push_back #define x first #define y second #define prev prev28 #define next next28 #define sqr(x) ((x) * (x)) #define sqrt(x) sqrt((double)(x)) #define pow(x, y) pow(1.0 * (x), (y)) #define pow2(y) (1LL<<(y)) #define pow2_(y) (2LL<<(y)) #define testbit(x, y) (((x)>>(y))&1) #define ispow2(x) ((x) != 0 && ((x)&((x) - 1)) == 0) #define bitcount(x) __builtin_popcountll(x) ll rightmostPower2(ll x) { return x ^ (x & (x - 1)); } ll largestPower2LE(ll n) { n = n | (n >> 1); n = n | (n >> 2); n = n | (n >> 4); n = n | (n >> 8); n = n | (n >> 16); n = n | (n >> 32); return (n + 1) >> 1; } #define INF 1e+9 #define INFLL 1e+18LL #define INTINF (~0U>>1) #define INTINFLL (~0ULL>>1) double getUserTime() { timeval tv; gettimeofday(&tv, 0); return tv.tv_sec + tv.tv_usec * 1e-6; } #define USERTIME() ({ double result = getUserTime(); fprintf(stderr, "User Time = %.6lf\n", result); \ fflush(stderr); result; }) #define TOTALTIME() ({ double result = (double) clock() / CLOCKS_PER_SEC; \ fprintf(stderr, "User+System Time = %.6lf\n", result); fflush(stderr); result; }) #define DOJOB(job) ({ double __begin = clock(); errno = 0; int result = (job); \ fprintf(stderr, "User+System Time = %.6lf\n", ((double) clock() - __begin) / CLOCKS_PER_SEC); \ fflush(stderr); result; }) #if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L) #define LLD "%I64d" #else #define LLD "%lld" #endif #define fastIO cin.sync_with_stdio(false), cin.tie(0) #define noFastIO cin.sync_with_stdio(true), cin.tie(cout) template void _R(T &x) { cin >> x; } template void _R(vector &x) { for (int i = 0; i < x.size(); ++i) _R(x[i]); } template void _R(T (&x)[N]) { for (int i = 0; i < N; ++i) { _R(x[i]); } } void _R(int &x) { scanf("%d", &x); } void _R(long long &x) { scanf(LLD, &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template void R(T (&x)[N], int n) { for (int i = 0; i < n; ++i) _R(x[i]); } template void R( T& head, U&... tail ) { _R(head); R(tail...); } template void _P(const T &x ) { cout << x; } void _P(const int &x ) { printf("%d", x); } void _P(const ll &x ) { printf(LLD, x); } template void _P(const vector &x ) { for (auto i = x.cbegin(); i != x.cend(); i++) { if (i != x.cbegin()) putchar(' '); _P(*i); } } template void _P(vector &x) { for (int i = 0; i < (int) x.size() - 1; ++i) { _P(x[i]); printf(" "); } if (x.size() >= 1) { _P(x[(int) x.size() - 1]); puts(""); } } void P() {} template void P(T (&x)[N], int n) { for (int i = 0; i < n - 1; ++i) { _P(x[i]); printf(" "); } if (n >= 1) { _P(x[n - 1]); puts(""); } } template void P(const T& head, const U&... tail) { _P(head); if (sizeof...(tail)) { printf(" "); P(tail...); } else { puts(""); } } #ifdef LOCAL template ostream& _out( ostream &s, Iter b, Iter e ) { s << "["; for (auto it = b; it != e; ++it) s << (it == b ? "" : " ") << *it; s << "]"; return s; } ostream& operator <<(ostream &s, const char *st) { return s << string(st); } template ostream& operator <<(ostream &s, const pair &p) { return s << "(" << p.first << "," << p.second << ")"; } template ostream& operator <<(ostream &s, const vector &c) { return _out(s, all(c)); } template ostream& operator <<(ostream &s, const array &c) { return _out(s, all(c)); } template ostream& operator <<(ostream &s, const set &c) { return _out(s, all(c)); } template ostream& operator <<(ostream &s, const map &c) { return _out(s, all(c)); } template ostream& operator <<(ostream &s, T (&c)[N]) { return _out(s, &c[0], &c[N]); } template void _show(T&& head) { cerr << head << endl; } template void _show(T&& head, Args&&... tail ) { cerr << head; fprintf(stderr, ", "); _show(tail...); } #define show(...) do { fprintf(stderr, "%s:%d - \"%s\" - ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__); _show(__VA_ARGS__); } while (0) #else #define show(...) #endif template void SORT(U& a) { sort(begin(a), end(a)); } template void SORT(T (&a)[N], int n) { sort(&a[0], &a[n]); } template void SORTR(U& a) { sort(begin(a), end(a), [](typename U::value_type x, typename U::value_type y) { return x > y; }); } template void SORTR(T (&a)[N], int n) { sort(&a[0], &a[n], [](T x, T y) { return x > y; }); } const double PI = acos(-1.0); inline void inc(int& a, int b, int p) { a += b; if (a >= p) a -= p; } inline void dec(int& a, int b, int p) { a -= b; if (a < 0) a += p; } inline int mul(int a, int b, int p) { return (ll) a * b % p; } template inline bool mx(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool mn(T& a, T b) { if (b < a) { a = b; return true; } return false; } int a[27]; int n; char s[12]; int solve(int testId) { rep(i, 26) {R(a[i]);} R(s); int num = strlen(s), h = 0; rep(i, num) { mx(h, a[s[i] - 'a']); } P(num * h); return EXIT_SUCCESS; } int main() { fastIO; #ifdef LOCAL int numTests = 3; rep(i, numTests) { int exitStatus = DOJOB(solve(i)); if (exitStatus != EXIT_SUCCESS) return exitStatus; } return EXIT_SUCCESS; #else return solve(0); #endif }