Buy Two Get One Free

Sort all prices from high to low and take every third pack free to pay the smallest possible total.

Easy3GreedySortingInterviewNo attempts yetTime limit1sMemory limit64 MB

Problem

The KSG convenience store runs a 2+1 sale on dairy products such as fruit milk and drinking yogurt. If you buy three dairy packs in one purchase, the cheapest of the three is free and you pay only for the other two. A purchase that does not contain exactly three packs gets no discount, so you pay the full price of every pack in it.

For example, suppose seven packs cost 10, 9, 4, 2, 6, 4 and 3, and Jaehyun buys them in three purchases: (10, 3, 2), (4, 6, 4) and (9). He pays 13 for the first purchase, 10 for the second and 9 for the third.

Jaehyun wants to buy all NN packs to share with his friends. He may split the packs into purchases however he likes. Find the minimum total cost of buying all NN packs.

Input

The first line contains the number of dairy packs NN. (1N100,0001 \le N \le 100{,}000)

Each of the next NN lines contains the price CiC_i of one pack. (1Ci100,0001 \le C_i \le 100{,}000)

Output

Print the minimum total cost of buying all NN packs on one line. The answer is at most 23112^{31}-1.