Minefield
During the mission, a reconnaissance team must navigate through enemy minefields. Due to the operation's secrecy, the mines will not be removed. The team has only one mine detector, so their movement strategy is as follows: two members cross the minefield towards the enemy, and then one member returns with the mine detector to the remaining group.
Each team member crosses the minefield at their own pace, and the crossing speed of a pair is determined by the slower member.
Your task is to calculate the minimum time required for the entire group of N
people to cross the minefield.
Input Data
The first line of the input provides the integer N
, representing the number of people in the group (2 ≤ N ≤ 100
). The following N
lines each contain a single integer, indicating the time in seconds it takes for each group member to cross the minefield (ranging from 1 to 600 seconds).
Output Data
Output a single integer on the first line, representing the minimum total time required for the entire group to successfully cross the minefield.