SP8329 ROADTRIP - Road trip

Description

Phileas Fogg and Passepartout are now going on a road trip in their brand new car. They start at location A $ _{0} $ and need to go to A $ _{N} $ . Their car has a capacity to hold only C units of fuel and can travel unit distance on unit amount of fuel. They start by filling some amount of fuel from the filling station at A $ _{0} $ . On the way, there are several filling stations A $ _{1} $ , A $ _{2} $ ,... A $ _{N-1} $ . The cost of fuel is not the same at all filling stations. Find the minimum amount that they have to spend on fuel to make the journey. Note that it is assured that the journey can be completed with the car of the given capacity.

Input Format

The first line of input contains T ( The first line in the description of each test case contains two space integers N (

Output Format

Output one integer per test case, the minimum total amount that needs to be spent on fuel to complete the journey