Under construction

Still being built. Things may change

Treating Freshmen to Cafeteria Meals

Time limit1sMemory limit1024 MB

Summary
Given N menu prices and M counter choices, the task is to print the sum of the prices each freshman picks.
Level

Easy1 of 10

Topics
Implementation, Array
Solved
No attempts yet

Problem

You are a fossil person who has agreed to treat the freshmen who just entered Kookmin University to cafeteria meals. The student cafeteria has several counters, each with its own number, and each counter sells a different meal. The freshmen want many different dishes, so working out the total bill is hard.

Given the price of the menu at each counter and the counter number that sells the meal each freshman wants, print the total amount you must pay.

Input

The first line contains the number of menu items NN. (1≤N≤10)(1\le N\le 10)

The next NN lines each contain a price. The ii-th of these lines contains the integer price AiA_i of the menu sold at the ii-th counter. (1000≤Ai≤10000)(1000\le A_i\le 10000)

The next line contains the number of freshmen MM. (1≤M≤10)(1\le M\le 10)

The next MM lines each contain BjB_j, the number of the counter that sells the meal the jj-th freshman wants. (1≤Bj≤N)(1\le B_j\le N)

Output

Print the total amount you must pay.

Examples1

  1. Example 1

    Input
    3
    3500
    4600
    4900
    2
    1
    3
    
    Expected output
    8400