Problem:
RSJ has a sequence a of n integers a1,a2,…,an and an integer s. For each of a2,a3,…,an−1, he chose a pair of non-negative integers xi and yi such that xi+yi=ai and (xi−s)⋅(yi−s)≥0.
Now he is interested in the value F=a1⋅x2+y2⋅x3+y3⋅x4+…+yn−2⋅xn−1+yn−1⋅an.
Please help him find the minimum possible value F he can get by choosing xi and yi optimally. It can be shown that there is always at least one valid way to choose them.
Input Format:
Each test contains multiple test cases. The first line contains an integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains two integers n, s (3≤n≤2⋅105; 0≤s≤2⋅105).
The second line contains n integers a1,a2,…,an (0≤ai≤2⋅105).
It is guaranteed that the sum of n does not exceed 2⋅105.
Output Format:
For each test case, print the minimum possible value of F.
Note:
In the first test case, 2⋅0+0⋅1+0⋅3+0⋅4=0.
In the second test case, 5⋅1+2⋅2+2⋅2+1⋅5=18.