No Change

No attempts yetTime limit1sMemory limit128 MB

Problem

Farmer John is at the market to buy supplies for his farm. He carries KK coins (1K161 \le K \le 16) in his pocket, and each coin has an integer value between 11 and 10810^8. John plans to make NN purchases (1N1051 \le N \le 10^5) in a fixed order, and purchase ii costs cic_i (1ci1041 \le c_i \le 10^4).

While he works through that sequence, John may stop at any point and pay. To pay he hands over a single coin, and that coin settles every purchase he made since his previous payment, so it has to be worth at least the total of those purchases. The vendors have no change at all, so when John hands over a coin worth more than he owes, the difference is gone.

A coin leaves his pocket for good once he uses it, so the money John is left with is the total value of the coins he never used. Compute the largest amount of money John can be left with after making all NN purchases in order. Print 1-1 if he cannot make all of his purchases.

Input

  • Line 1: two integers KK and NN.
  • Lines 2 through 1+K1+K: each line contains the value of one of John's coins.
  • Lines 2+K2+K through 1+N+K1+N+K: these NN lines contain the costs of John's intended purchases, in order.

Output

  • Line 1: print the largest amount of money John can be left with, or 1-1 if he cannot make all of his purchases.

Hint

In the example John has three coins worth 1212, 1515, and 1010, and he must make purchases of 66, 33, 33, 22, 33, and 77 in that order. He pays for the first two purchases with the 1010 coin (6+3=9106 + 3 = 9 \le 10) and for the remaining four with the 1515 coin (3+2+3+7=153 + 2 + 3 + 7 = 15). The 1212 coin stays in his pocket.