主页 讨论版 问题 名次 状态 统计
欢迎加入西电微软俱乐部招新群 588166170,做出福利题,免技术部第一次面试且赠送“福利”海报或小礼品~~~~
问题 E: ship

问题 E: ship

时间限制: 1 Sec  内存限制: 128 MB
提交: 39  解决: 23
[提交][状态][讨论版]

题目描述

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.

输入

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

样例输出

22

提示

[提交][状态][讨论版]