Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.

In this game, the phone's screen is divided into four vertical strips. Each second, a black square appears on some of the strips. According to the rules of the game, Jury must use this second to touch the corresponding strip to make the square go away. As Jury is both smart and lazy, he counted that he wastes exactly a_{i} calories on touching the i-th strip.

You've got a string s, describing the process of the game and numbers a_1, a_2, a_3, a_4. Calculate how many calories Jury needs to destroy all the squares?


-----Input-----

The first line contains four space-separated integers a_1, a_2, a_3, a_4 (0 ≤ a_1, a_2, a_3, a_4 ≤ 10^4).

The second line contains string s (1 ≤ |s| ≤ 10^5), where the і-th character of the string equals "1", if on the i-th second of the game the square appears on the first strip, "2", if it appears on the second strip, "3", if it appears on the third strip, "4", if it appears on the fourth strip.


-----Output-----

Print a single integer — the total number of calories that Jury wastes.


-----Examples-----
Input
1 2 3 4
123214

Output
13

Input
1 5 3 2
11221

Output
13

Difficulty: interview

Starter code:

Solutions:
s = 0
a = list(map(int, input().split()))
for i in map(int, input()):
    s += a[i - 1]
print(s)

a=list(map(int,input().split()))

s=input()

ans=0
for item in s:
    ans+=a[int(item)-1]
print(ans)


a = list(map(int, input().split()))
s = input().strip()
ans = 0
for i in s:
    ans += a[int(i) - 1]
    
print(ans)


a, b, c, d = map(int, input().split())
res = 0
s = input()
n = len(s)
for i in range(n) :
    if s[i] == '1' :
        res += a;
    if s[i] == '2' :
        res += b;
    if s[i] == '3' :
        res += c;
    if s[i] == '4' :
        res += d;
print(res)

a=list(map(int,input().split()))
s=input().strip()
ans=0
for i in range(len(s)):
    ans+=a[int(s[i])-1]
print(ans)

a1, a2, a3, a4 = map(int, input().split())
a = list(map(int, input()))
sum = 0
for i in range(len(a)):
    if a[i] == 1:
        sum += a1
    elif a[i] == 2:
        sum += a2
    elif a[i] == 3:
        sum += a3
    else:
        sum += a4
print(sum)

a=list(map(int, input().split()))
s=input()
ans=0
for i in range(len(s)):
    ans+=a[int(s[i])-1]
print(ans)


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = "sonhuytran@gmail.com"
__doc__ = ''
__version__ = '1.0'


def main() -> int:
    a = [int(word) for word in input().split()]
    game = input()

    calories = {
        '1': a[0],
        '2': a[1],
        '3': a[2],
        '4': a[3]
    }
    sum_calories = 0

    for brick in game:
        sum_calories += calories[brick]

    print(sum_calories)
    return 0


def __starting_point():
    exit(main())
__starting_point()

a = list(map(int, input().split()))
s = input()
print(sum([a[int(c) - 1] for c in s]))

import sys

f = sys.stdin
a = [int(u) for u in f.readline().strip().split()]

s = f.readline().strip()

res = 0
for u in s:
    res += a[int(u)-1]

print(res)    


import collections


a = tuple(map(int, str.split(input())))
ns = collections.Counter(list(map(int, str.strip(input()))))
print(sum([a[i - 1] * ns[i] for i in ns]))


import random
import sys
#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')
a = [0] * 5
ans = 0
a[1], a[2], a[3], a[4] = list(map(int, input().split()))
s = input()
for i in s:
    ans += a[ord(i) - 48]
print(ans)


game = list(map(int, input().split()))
seq = list(map(int, list(input())))

c = 0

for i in seq:
    c+=game[i-1]
print(c)


a = [int(x) for x in input().split(' ')]
s = input()
count = 0
for i in s:
    if i == '1':
        count += a[0]
    elif i == '2':
        count += a[1]
    elif i == '3':
        count += a[2]
    else:
        count += a[3]
print(count)


import sys
#sys.stdin = open('input.txt', 'r')

a = list(map(int, input().split()))
S = input()
k = 0
for s in S:
	k += a[int(s)-1]
print(k)







a = input().split()

ans = 0
s = input()

for i in s:
    if (i == '1'): ans += int(a[0])
    if (i == '2'): ans += int(a[1])
    if (i == '3'): ans += int(a[2])
    if (i == '4'): ans += int(a[3])
    
print(ans)

c = list(map(int,input().split()))
sum = 0
s = input().strip()
for i in range (len(s)):
    sum += c[int(s[i])-1]
print(sum)
                


cal = list(map(int,input().split()))
s = input()
tot = 0
for i in range(len(s)):
    tot += cal[int(s[i])-1]
print(tot)


a1,a2,a3,a4=list(map(int,input().split()))
s=input()
k=0
for i in range(len(s)):
    if s[i]=='1':
        k+=a1
    if s[i]=='2':
        k+=a2
    if s[i]=='3':
        k+=a3
    if s[i]=='4':
        k+=a4
print(k)


#!/usr/bin/env python

def main( ):
    a1, a2, a3, a4 = list(map( int, input( ).split( ) ))

    res = 0
    for s in input( ):
        if s == '1': res += a1
        if s == '2': res += a2
        if s == '3': res += a3
        if s == '4': res += a4

    print( res )


def __starting_point():
    main( )


__starting_point()

kal = []
kal = [int(x) for x in input().split()]
s = input()
print(sum([kal[int(x) - 1] for x in s]))


calEach=input().split()
squares=list(input())
calTot=0
for i in squares:
    n=int(i)-1
    calTot+=int(calEach[n])
print(calTot)