eolymp
bolt
Try our new interface for solving problems
Problems

Discounts

Discounts

Time limit 1 second
Memory limit 64 MiB

When you visited large shop before New Year, you chose a lot of gifts to relatives and to the friends. If you want to economize the certain quantity of money then two types of pre-New Year discounts can help you which operate in a shop:

1. If you want to buy three commodities you will pay for them as for two dearest of them.

2. If you want to buy four commodities you will pay for them as for three dearest of them.

Thus, you can inite certain commodities in three or four and pay for them less. It is needed to define the least possible sum of money, which will be expended in acquisition of all of gifts. For example, if prices of 5 heel select gifts make: 50, 80, 50, 100, 20, it is possible separately to purchase four first commodities, get a discount for them, and then to purchase a gift which remained for his nominal price. All of purchase will cost 250 monetary items, in place of 300 eventually.

You have to write a task program, which can find the minimum sum of money, which will last their purchase after the costs of all gifts.

Input data

The first line contains one integer N (0 N 10000). The second line contains N natural numbers. There are costs of gifts. The sum of costs of all gifts is less than 10^9. It is possible to unite not only those commodities which go successively in the input.

Output data

Print one integer - the minimum sum of money, for which it is possible to purchase all the gifts.

Examples

Input example #1
5
50 80 50 100 20
Output example #1
250
Author Shamil Yagiyaev
Source 2008 XXI All-Ukrainian Informatics Olympiad, Lvov, April 5 - 11, Round 2