MZL is a mysterious mathematician, and he proposed a mysterious function at his young age.
Stilwell is very confused about this function, and he need your help.
First of all, given n positive integers Ai and Ai≥Ai+1.
Then, generate n positive integers Bi
Define f(i,j) for i,j∈Z
Find f(n,1).
The first line of the input contains a single number T, the number of test cases.
For each test case, the first line contains a positive integer n, and the next line contains n positive integers Ai.
T≤100, 1≤n≤105, ∑n≤106, 1≤Ai≤104.
For each test case, output f(n,1) in a line.
3 3 1 1 1 5 28 26 25 24 1 10 996 901 413 331 259 241 226 209 139 49
5 233 11037
case 1 :f(1,1)=0f(1,2)=f(1,1)+3=3f(1,3)=f(1,2)+3=6f(2,1)=min(f(2,1)+2,f(1,2))=3f(2,2)=min(f(2,1)+2,f(1,3))=5f(2,3)=f(2,2)+2=7f(3,1)=min(f(3,1)+1,f(2,2))=5