A - Contest Result Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 100

問題文

N 問の問題からなるコンテストが開催され、i\ (1\leq i\leq N) 問目の配点は A_i 点でした。

すぬけくんはこのコンテストに参加し、B_1,B_2,\ldots,B_M 問目の M 問を解きました。 すぬけくんの総得点を求めてください。

ただし、総得点とは解いた問題の配点の総和を意味するものとします。

制約

  • 1\leq M \leq N \leq 100
  • 1\leq A_i \leq 100
  • 1\leq B_1 < B_2 < \ldots < B_M \leq N
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N M
A_1 A_2 \dots A_N
B_1 B_2 \dots B_M

出力

答えを整数として出力せよ。


入力例 1

3 2
10 20 30
1 3

出力例 1

40

すぬけくんは 1 問目と 3 問目を解きました。 配点はそれぞれ 10 点と 30 点なので、総得点は 10+30=40 点です。


入力例 2

4 1
1 1 1 100
4

出力例 2

100

入力例 3

8 4
22 75 26 45 72 81 47 29
4 6 7 8

出力例 3

202

Score : 100 points

Problem Statement

There was a contest with N problems. The i-th (1\leq i\leq N) problem was worth A_i points.

Snuke took part in this contest and solved M problems: the B_1-th, B_2-th, \ldots, and B_M-th ones. Find his total score.

Here, the total score is defined as the sum of the points for the problems he solved.

Constraints

  • 1\leq M \leq N \leq 100
  • 1\leq A_i \leq 100
  • 1\leq B_1 < B_2 < \ldots < B_M \leq N
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

N M
A_1 A_2 \dots A_N
B_1 B_2 \dots B_M

Output

Print the answer as an integer.


Sample Input 1

3 2
10 20 30
1 3

Sample Output 1

40

Snuke solved the 1-st and 3-rd problems, which are worth 10 and 30 points, respectively. Thus, the total score is 10+30=40 points.


Sample Input 2

4 1
1 1 1 100
4

Sample Output 2

100

Sample Input 3

8 4
22 75 26 45 72 81 47 29
4 6 7 8

Sample Output 3

202