Minefield#2000

Minefield

1 second
64 megabytes
Hard

During the mission, a reconnaissance team must navigate through enemy minefields. To maintain secrecy, the mines cannot be removed. The team has only one mine detector, so the movement must be organized as follows: two people cross the minefield together towards the enemy side, then one person returns with the mine detector for the remaining group.

Each person crosses the minefield at their own speed. The speed of a pair is determined by the slower member.

Calculate the minimum time required for the whole group to cross the minefield.

Input

The first line contains the integer — the number of people in the group, where 2 \leq N \leq 100.

The following lines contain the time required for each group member to cross the minefield (from to seconds, all values are integers).

Output

Output a single integer: the minimum total time required for all group members to cross the minefield.

Examples

Example 1

Loading
Loading