Circleland

No attempts yetTime limit1sMemory limit256 MB

Problem

You are visiting Circleland, and you finally walk into the famous art exhibition you have wanted to see for a long time. The exhibition has NN rooms arranged in a cycle, and every room holds some artistic pieces. The rooms are named R1,R2,,RNR_1, R_2, \dots, R_N. There are also NN corridors, named C1,C2,,CNC_1, C_2, \dots, C_N, of lengths L1,L2,,LNL_1, L_2, \dots, L_N respectively. Corridor CiC_i connects rooms RiR_i and Ri+1R_{i+1}, and CNC_N connects rooms RNR_N and R1R_1. The whole exhibition therefore forms a cycle. You can walk in both directions in every corridor.

There is a single entrance in room R1R_1, and there is an exit in every room. Nothing in the corridors is worth seeing, so you want to walk as little as possible inside them. Compute the minimum total distance you have to walk in corridors if you enter through the entrance, visit all rooms, and leave through any exit.

Input

The first line contains one integer TT, the number of test cases. (1T1001 \le T \le 100)

Each of the next TT lines contains one test case. A case starts with an integer NN, the number of rooms in the exhibition (2N1000002 \le N \le 100\,000), followed by NN numbers, the lengths of the corridors L1,L2,,LNL_1, L_2, \dots, L_N in this order. (1Li10000001 \le L_i \le 1\,000\,000)

The sum of the lengths of all corridors does not exceed 10000000001\,000\,000\,000.

Output

For each test case, print on a single line the minimum total distance you have to walk in corridors to visit all rooms.