Ivan and his friends (a total of freaks) are about to have dinner. As they enter the restaurant they see a big sign that says
“2 1: Bring a companion and one of you (whoever would pay less) eats for free.”
After everyone has decided what he wants to eat (one or more dishes), they start wondering what is the minimum total price that they can achieve. They must decide the following:
Who should order what.
Who should be whose companion, so that the offer can be applied on each pair.
As long as every dish is ordered by someone, it does not matter by who (dishes can be rearranged after the waiter brings them to the table). There is no upper limit on the number of dishes that a single person can order. Also, having someone not ordering anything is perfectly fine.
For instance, if five people , , , and want six dishes with prices 10, 15, 20, 23, 30 and 42, then an optimal solution is to have not ordering anything, ordering 10 and 20, ordering 30, ordering 15 and 23, ordering 42, and then to use the offer with the pair and (they pay 30) and with the pair and (they pay 42), for a total price of 72.
Given and the prices of the dishes, can you find out what is the minimum total amount that Ivan and his friends have to pay?
Input consists of several cases, only with integer numbers. Each case begins with , followed by the total number of dishes , followed by the prices of the dishes, all between 1 and 100. Assume .
Print the minimum total price that Ivan and his friends can achieve thanks to the 2 1 offer.
Input
5 6 10 15 20 23 30 42 2 2 40 30 2 3 30 30 30
Output
72 40 60