Problem Description
We had discussed about collections mode in python. Let's try the following problem using it.
There are N shops in the street and each shop has only single type of chocolate.
There are M number of children who are willing to pay Xi amount of money only if they get the chocolate of their desired type.
Find the total amount earned by all shopkeepers
Problem Constraints
1 <= N, M <= 105
1 <= Xi <= 109
1 <= Type of chocolate <= 109
Input Format
First line consist of an integer N.
Second line consist of N space separated integers denoting the type of chocolate at N shops.
Third line consist of an integer M.
Each of the next M lines consist of two integers Xi and type of desired chocolate.
Output Format
Print the total amount earned by all shopkeepers.
Example Input
Input 1:
10 1 2 1 3 2 5 6 10 11 15 5 50 1 20 3 25 3 5 12 20 11
Input 2:
5 11 11 2 3 2 4 50 2 10 2 20 2 100 2
Example Output
Output 1:
90
Output 2:
60
Example Explanation
Explanation 1:
1st, 2nd and 5th children will get the chocolate, so the total money earned is 90.
Explanation 2:
1st and 2nd children will get the chocolate, so the total money earned is 60.