You are given a sequence a1,a2,…,an. In one step you can pick two adjacent numbers ai and ai+1 and replace both of them with the single number max(ai,ai+1). That step costs max(ai,ai+1). Each step makes the sequence one shorter, so after n−1 steps a single number is left.
Given the sequence, compute the minimum total cost of reducing it to length 1.
The first line contains the number of test cases T (1≤T≤100000).
Each test case takes two lines. The first line contains the length of the sequence N (2≤N≤5000). The second line contains the N integers of the sequence, separated by single spaces. Every integer is between 1 and 100000 inclusive.
For each test case, print one line in the format Case #x: R, where x is the test case number starting from 1 and R is the minimum cost of reducing that sequence to length 1.