S brought a new Handheld game console, which is powered by two No.5
batteries. In order to play games for a long time, he brought lots of No.5
batteries as well. These batteries have different manufacturers and qualities.
Therefore their service hours varies. Some can be used for 5 hours, others can
only be used for 3 hours. So if he only have two batteries, one has 5 hours
service life, the other has 3 hours, then he can only play games for 3 hours. The
remaining battery in the 5-hours battery can not be used. But if he has more
batteries, he is able to use them wisely. For example, he has three batteries,
which has service life of 3,3 and 5 hours respectively. Then he can use the two
3-hours batteries first. After half hour usage, he changed one of them into the
5-hours battery. Then again after two and a half hours, replace the 3-hours
battery into the one not in use. By doing this, he is able to paly for 5.5
hours, without any waste of battery.
Now given the number of batteries and their service life, find a method to
use those batteries so that S can play games as long as possible.
The input contains multiple sets of
data. Each set of data consists of two lines. The first line is an integer N (2
≤ N ≤ 1000), indicating the number of batteries. The next line has N positive
integers indicating the service life of the battery.
2
3 5
3
3 3 5
3.0
5.5