Codeforces Round 247 (Div. 2)
A
Black Square
Codeforces
800
原题
←B →
翻译中…

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.

翻译中…

样例

Input #1
1 2 3 4
123214
Output #1
13
InputCopy OutputCopy
Input #2
1 5 3 2
11221
Output #2
13
InputCopy OutputCopy
题目信息
题号
431A
时间限制
1 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。