#3312. [USACO2013 Nov] No Change

[USACO2013 Nov] No Change

Description

Farmer John is at the market to purchase supplies for his farm. He has in his pocket KK coins. FJ would like to make a sequence of NN purchases, where the ith purchase costs cic_i units of money. As he makes this sequence of purchases, he can periodically stop and pay, with a single coin, for all the purchases made since his last payment (of course, the single coin he uses must be large enough to pay for all of these). Unfortunately, the vendors at the market are completely out of change, so whenever FJ uses a coin that is larger than the amount of money he owes, he sadly receives no changes in return!

Please compute the maximum amount of money FJ can end up with after making his NN purchases in sequence. Output 1-1 if it is impossible for FJ to make all of his purchases.

Input

Line 11: Two integers, K,NK,N.

Lines 21+K2\sim 1+K: Each line contains the amount of money of one of FJ's coins.

Lines 2+K1+N+K2+K\sim 1+N+K: These NN lines contain the costs of FJ's intended purchases.

Output

Line 11: The maximum amount of money FJ can end up with, or 1-1 if FJ cannot complete all of his purchases.

3 6
12
15
10
6
3
3
2
3
7
12 

Sample Explain 1

FJ has 33 coins of values 12,15,1012,15,10. He must make purchases in sequence of value 6,3,3,2,3,76,3,3,2,3,7.

FJ spends his 1010-unit coin on the first two purchases, then the 1515-unit coin on the remaining purchases. This leaves him with the 1212-unit coin.

Data scale and Agreement

For 100%100\% data, 1K161\leq K\leq 16, 1N1051\leq N\leq 10^5, the value of each coin in the range 11081\sim 10^8, 1ci1041\leq c_i\leq 10^4.

Source

Gold