Cow Rental Service

Choose for each cow whether to milk it or rent it, matching milk to stores with limited quantity and price, to maximize total cents.

Medium6GreedySortingTwo pointersBinary searchInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Farmer John decided that milk sales alone do not bring in enough money to grow his farm. To earn extra income he started a service that rents his cows out.

Farmer John has NN cows, and each cow produces a fixed amount of milk per day. There are MM stores near the farm, and each store buys milk up to a fixed amount at a fixed price per gallon. RR neighboring farmers each want to rent one cow for a day at a fixed price.

For every cow Farmer John picks one of two options: milk it, or rent it out to a neighbor. Find the largest amount of money he can make in one day.

Input

The first line contains NN, MM, and RR (1N100,0001 \leq N \leq 100,000, 1M100,0001 \leq M \leq 100,000, 1R100,0001 \leq R \leq 100,000).

Each of the next NN lines contains one integer cic_i (1ci1,000,0001 \leq c_i \leq 1,000,000), meaning that the iith cow produces cic_i gallons of milk per day.

Each of the next MM lines contains two integers qiq_i and pip_i (1qi,pi1,000,0001 \leq q_i, p_i \leq 1,000,000), meaning that the iith store buys up to qiq_i gallons of milk at pip_i cents per gallon. Farmer John may sell any amount between 00 and qiq_i gallons to that store.

Each of the next RR lines contains one integer rir_i (1ri1,000,0001 \leq r_i \leq 1,000,000), meaning that one neighbor pays rir_i cents to rent one cow for a day.

Output

Print one line with the largest daily profit Farmer John can make by milking or renting out each of his cows. The answer can exceed the range of a 32-bit integer, so use a 64-bit integer type.

Hint

In the first example Farmer John milks cow 1 and cow 4 and gets 13 gallons. He fills the order for 10 gallons and earns 250 cents, then sells the remaining 3 gallons at 15 cents per gallon, so milk brings in 295 cents. He rents the other three cows out for 250, 80, and 100 cents, which adds 430 cents. He turns down the 40-cent rental request. The daily profit is 725 cents in total.