B-stock#2832

B-stock

1 sekunt
128 megabaýt
Örän ýeňil

The famous businessman in Berland, Vasechkin, has barrels of gasoline stored at the B-warehouse. The barrels are arranged in a row and numbered from to . A year ago, Vasechkin conducted an inspection, so he knows how many liters of gasoline were in each barrel at that time.

When a new order for liters of gasoline arrived, the workers followed a simple algorithm: they poured it out from the barrel with the smallest number that had enough gasoline. If no such barrel was found, the order was ignored.

Now, Vasechkin wants to know how much gasoline remains, since he does not wish to conduct another full inspection. Help him determine the amount of gasoline left in all barrels.

Giriş

The first line contains the integer (1 \leq n \leq 10^5).

The second line contains integers, each not greater than , representing the amount of gasoline in each barrel a year ago. Barrels are listed in order from to .

The third line contains the integer (1 \leq k \leq 30000).

The fourth line contains integers, each not greater than , representing the number of liters in each order, listed in the order they arrived.

Çykyş

Print the total number of liters of gasoline remaining at Vasechkin's warehouse.

Mysallar

1-nji mysal

Loading
Loading