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 N rooms arranged in a cycle, and every room holds some artistic pieces. The rooms are named R1,R2,…,RN. There are also N corridors, named C1,C2,…,CN, of lengths L1,L2,…,LN respectively. Corridor Ci connects rooms Ri and Ri+1, and CN connects rooms RN and R1. The whole exhibition therefore forms a cycle. You can walk in both directions in every corridor.
There is a single entrance in room R1, 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.
The first line contains one integer T, the number of test cases. (1≤T≤100)
Each of the next T lines contains one test case. A case starts with an integer N, the number of rooms in the exhibition (2≤N≤100000), followed by N numbers, the lengths of the corridors L1,L2,…,LN in this order. (1≤Li≤1000000)
The sum of the lengths of all corridors does not exceed 1000000000.
For each test case, print on a single line the minimum total distance you have to walk in corridors to visit all rooms.