The members of XDU-ACM group went camp this summer holiday. They came across a river one day. There was a ship which only can carry at most two people at the same time. The ship would move only if there is at least one person in the ship to drive it. Everyone had different cost of time to pass the river, and the time of pass the river by ship depended on the longer time of the two passengers. You should tell them the minimum total time that all of the members should spend to arrive the next band.
问题 E: ship时间限制: 1 Sec 内存限制: 128 MB
提交: 46 解决: 27
The input contains multiple test cases.
The first line of each case contains one integer n (1≤n≤100000). Then next n lines contains n positive integers a[i](1≤a[i]≤10000)-the ith person spend a[i] time to pass the river.
For each case ,print the minimum total time they should spend in the only line.
4 2 3 6 11