#include using namespace std; typedef long long ll; typedef pair pii; typedef vector vii; #define X first #define Y second #define rep(i,n) for(ll i=0; i<(n); i++) #define repp(i,a,b) for(ll i=a; i<=(b); i++) #define repp2(i,b,a) for(ll i=b; i>=(a); i--) #define fill(a,val) memset(a, (val), sizeof(a)) #define mp make_pair #define pb push_back #define all(c) (c).begin(), (c).end() #define uni(c) c.resize(distance(c.begin(), unique(all(c)))) #define io ios_base::sync_with_stdio(false);cin.tie(NULL); #define sc(num) scanf("%lld",&num) //#define ONLINE #ifdef ONLINE FILE *fin = freopen("great.in","r",stdin); FILE *fout = freopen("great.out","w",stdout); #endif ll mod= 1e9 + 7, mod1=1e9+9; double eps = 1e-16; const ll N=100005; int main(){ io; int a[26]; rep(i,26)cin>>a[i]; string s; cin>>s; int ma=0; for(auto x:s){ ma=max(ma,a[x-'a']); } cout<