#include <bits/stdc++.h>
using namespace std;
long a[10];
long ans;
char x;
int main() {
  for (long i = 1; i <= 4; i++) {
    scanf("%ld", a + i);
  }
  scanf("\n");
  while (scanf("%c", &x) != EOF) {
    ans += a[x - '0'];
  }
  printf("%ld\n", ans);
  return 0;
}
