#include using namespace std; typedef long long ll; typedef long double ld; int cost[26]; char buf[107]; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif for (int i = 0; i < 26; i++) { scanf("%d", &cost[i]); } scanf("\n"); scanf("%s", buf); int n = strlen(buf); int mx = 0; for (int i = 0; i < n; i++) { mx = max(mx, cost[buf[i] - 'a']); } printf("%d\n", mx * n); return 0; }