AT_past17_c 換金

Description

Takahashi has $ N $ cards. For $ i = 1, 2, \ldots, N $ , his $ i $ -th card has an integer $ A_i $ between $ 1 $ and $ 10 $ written on it. For $ x = 1, 2, \ldots, 10 $ , a card with the integer $ x $ written on it can be changed into $ P_x $ yen (currency in Japan). Find the total amount of money Takahashi can get by changing all his cards into money.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $ $ P_1 $ $ P_2 $ $ \ldots $ $ P_{10} $

Output Format

Print the answer as an integer.

Explanation/Hint

### Sample Explanation 1 - The $ 1 $ -st card has an integer $ 3 $ written on it, which is worth $ P_3 = 59 $ yen. - The $ 2 $ -nd card has an integer $ 10 $ written on it, which is worth $ P_{10} = 84 $ yen. - The $ 3 $ -rd card has an integer $ 7 $ written on it, which is worth $ P_7 = 97 $ yen. - The $ 4 $ -th card has an integer $ 3 $ written on it, which is worth $ P_3 = 59 $ yen. Thus, he can change all his cards into money to get a total of $ 59 + 84 + 97 + 59 = 299 $ yen. ### Sample Explanation 2 The answer may not fit into a $ 32 $ -bit integer type. ### Constraints - $ 1 \leq N \leq 10 $ - $ 1 \leq A_i \leq 10 $ - $ 1 \leq P_x \leq 10^9 $ - All input values are integers.