To fulfill an assignment, a reconnaissance group of n people must cross the
enemy's minefield. Since the group has only one mine detector, the following
course of action is taken: two agents cross the field to the enemy's side and
then one agent brings the mine detector back to the remaining group. This is
repeated until only two agents remain. These two agents then cross the field
Each person gets across the field at their own speed. The speed of a pair is
determined by the speed of its slower member.
Find the minimal time the whole group needs to get over the minefield.
The first line contains the integer n (2 ≤ n ≤ 100). The i-th of
the following n lines specifies the time the i-th member of the group needs
to get over the minefield (the time is an integer from 1 to 600).
Output the minimal total time the group needs to cross the minefield.
Problem Author: Dmitry Teryaev
Problem Source: XII USU Open Personal Contest (March 19, 2011)