#include <bits/stdc++.h>
using namespace std;
int t, a[1111111];
char c;
int main() {
  scanf("%d%d%d%d", a, a + 1, a + 2, a + 3);
  for (c = getchar(); !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar()) t += a[c - 49];
  printf("%d", t);
}
