#include using namespace std; typedef long long ll; #define pii pair #define pll pair #define pdd pair #define X first #define Y second #define REP(i,a) for(int i=0;i0){ if(y%2) y-=1,t=t*x%mod; else y/=2,x=x*x%mod; } return t; } #ifdef DEBUG #define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__) #else #define dprintf(fmt,...) #endif int a[26]; char s[N]; int main(){ REP(i,26) scanf("%d",&a[i]); scanf("%s",s); int n=strlen(s),x=0; REP(i,n) x=max(x,a[s[i]-'a']); printf("%lld\n",1ll*x*n); return 0; }