#abc290a. A - Contest Result

A - Contest Result

Score : 100100 points

问题描述

有一场包含 NN 道题目的比赛。第 ii 题(1iN1\leq i\leq N)的分值为 AiA_i 分。

Snuke 参加了这场竞赛并解决了 MM 道题目:分别是第 B1B_1B2B_2\ldotsBMB_M 题。请计算他的总分。

这里,总分定义为他所解题目的分数之和。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

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

Snuke took part in this contest and solved MM problems: the B1B_1-th, B2B_2-th, \ldots, and BMB_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

  • 1MN1001\leq M \leq N \leq 100
  • 1Ai1001\leq A_i \leq 100
  • 1B1<B2<<BMN1\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:

NN MM

A1A_1 A2A_2 \dots ANA_N

B1B_1 B2B_2 \dots BMB_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 11-st and 33-rd problems, which are worth 1010 and 3030 points, respectively. Thus, the total score is 10+30=4010+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

update @ 2024/3/10 12:06:13

}