#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> p(5, 0), k(5);
  int n = 4;
  for (int i = 1; i <= n; i++) cin >> k[i];
  string s;
  cin >> s;
  int len = s.size();
  for (int i = 0; i < len; i++) p[s[i] - 48]++;
  int res = 0;
  for (int i = 1; i <= n; i++) res += p[i] * k[i];
  cout << res;
}
