You are given N numbers – v_1,v_2,…,v_N, and an integer A. You can do an unlimited number of swaps in the array by swapping v_i and v_i+1 for a cost of v_i+v_i+1. The new array after the swap would then be v1,…,v_i+1,v_i,…,v_N. For a certain number R, your task it to find the minimum sum of the costs of your swaps and (v_1+v_2+⋯+v_R)×A. Given Q queries and an R_i for each of them, find the minimum cost you can achieve for each query. All queries are independent.
There are 3 integers on the first line: N – the size of the array, Q – the number of queries and A – the coefficient (v_1+v_2+⋯+v_R) is multiplied by. The second line of the input contains N positive integers v_1,v_2,…,v_N - the starting array. The last line holds the positive integers R_1,…,R_Q.
On each of the Q lines output the minimum cost for the corresponding query.
Example №1: It is optimal to not swap any elements. The cost is then (4+1)×5=25.
Example №2: We can first swap 4 with 1 and then 4 with 2:
The costs of the swaps are 4+1=5 and 4+2=6. Therefore, the total cost is
5+6+(1+2)×6=29.