eolymp
bolt
Try our new interface for solving problems
Problems

B-stock

B-stock

The famous businessman in Berland Vasechkin has at B-stock n barrels of gasoline. They stand in a row and numbered from 1 to n. A year ago Vasechkin carried out an inspection, so he knows how many liters of gasoline was in each barrel at that time. When a new order for q liters of gasoline arrived, the workers acted on a very simple algorithm. They pour it out of the barrel with the lowest number in which there was enough petrol. If such barrel did not exist, the order was ignored. Now Vasechkin wants to know how much gasoline left, because he do not want to make the regular inspection. Help him.

Input

The first line contains number n (1n105). The second line contains n numbers not greater than 1000 - amount of gasoline in barrels a year ago. The barrels are listed in increasing order of their numbers. The third line contains the number of orders k (1k30000). The fourth line gives k numbers not greater than 1000 - the number of liters in orders. The queries are listed in the order of their arrival.

Output

Print the number of liters of gasoline s, remained at Vasechkin.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
10 5 10
4
7 8 4 4 
Output example #1
6