You are given an array of elements and a constant . You can perform the following operation on the array —
Calculate the minimum cost to reduce the array to only one element, by performing the mentioned operation as many times needed.
First line of input will contain an integer denoting the number of test cases.
For each test case, the first line contains two integers and , and the second line contains integers .
.
.
.
.
For each test case, output a line in the format “Case i: x” without the quotes, where is the minimum cost to reduce the array to only one element, by performing the mentioned operation as many times needed.
Input | Output |
---|---|
1 4 3 1 2 3 4 | Case 1: 13 |