#abc288e. [abc288_e]Wish List

[abc288_e]Wish List

Problem Statement

There are NN items in a shop, numbered as Item 11, Item 22, ldots\\ldots, Item NN.
For each i=1,2,ldots,Ni = 1, 2, \\ldots, N, the regular price of Item ii is AiA_i yen. For each item, there is only one in stock.

Takahashi wants MM items: Item X1X_1, Item X2X_2, ldots\\ldots, Item XMX_M.

He repeats the following until he gets all items he wants.

Let rr be the number of unsold items now. Choose an integer jj such that 1leqjleqr1 \\leq j \\leq r, and buy the item with the jj-th smallest item number among the unsold items, for its regular price plus CjC_j yen.

Print the smallest total amount of money needed to get all items Takahashi wants.

Takahashi may also buy items other than the ones he wants.

Constraints

  • 1leqMleqNleq50001 \\leq M \\leq N \\leq 5000
  • 1leqAileq1091 \\leq A_i \\leq 10^9
  • 1leqCileq1091 \\leq C_i \\leq 10^9
  • 1leqX1ltX2ltcdotsltXMleqN1 \\leq X_1 \\lt X_2 \\lt \\cdots \\lt X_M \\leq N
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN MM A1A_1 A2A_2 ldots\\ldots ANA_N C1C_1 C2C_2 ldots\\ldots CNC_N X1X_1 X2X_2 ldots\\ldots XMX_M

Output

Print the answer.


Sample Input 1

5 2
3 1 4 1 5
9 2 6 5 3
3 5

Sample Output 1

17

Here is a way for Takahashi to get all items he wants with the smallest total amount of money.

  • Initially, five items, Items 1,2,3,4,51, 2, 3, 4, 5, are remaining. Choose j=5j = 5 to buy the item with the fifth smallest item number among the remaining, Item 55, for A5+C5=5+3=8A_5 + C_5 = 5 + 3 = 8 yen.
  • Then, four items, Items 1,2,3,41, 2, 3, 4, are remaining. Choose j=2j = 2 to buy the item with the second smallest item number among the remaining, Item 22, for A2+C2=1+2=3A_2 + C_2 = 1 + 2 = 3 yen.
  • Then, three items, Items 1,3,41, 3, 4, are remaining. Choose j=2j = 2 to buy the item with the second smallest item number among the remaining, Item 33, for A3+C2=4+2=6A_3 + C_2 = 4 + 2 = 6 yen.

Now, Takahashi has all items he wants, Items 33 and 55, (along with Item 22, which is not wanted) for a total cost of 8+3+6=178 + 3 + 6 = 17 yen, the minimum possible.


Sample Input 2

20 8
29 27 79 27 30 4 93 89 44 88 70 75 96 3 78 39 97 12 53 62
32 38 84 49 93 53 26 13 25 2 76 32 42 34 18 77 14 67 88 12
1 3 4 5 8 14 16 20

Sample Output 2

533