#P470. 【例85.3】 过河问题

【例85.3】 过河问题

Description

There are nn people and one boat. Everyone needs to cross the river from the left bank to the right bank. The crossing time for the ii-th person is aia_i. The boat can carry at most two people, and when returning from the right bank to the left bank, there must be someone on the boat. The travel time of the boat equals the maximum crossing time of the two people on board.
What is the minimum time needed for everyone to cross the river?

Input Format

Input tt test cases. For each test case, the first line contains nn, and the second line contains nn numbers representing the crossing time for each person.

Output Format

Output tt lines, each containing one number representing the minimum crossing time for each test case.

Sample

1
4
1 2 5 10
17