Discounts-2
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
In an electronics supermarket, a discount system is in place: if you buy one item, you pay the full price. If you purchase two items, you get a 50% discount on the cheaper item. For three items, the cheapest one is free. Determine the minimum amount you need to pay when buying N items, given that the prices of these items in hryvnias are listed in the array C[1..N].
Input data: The first line contains the integer N (1 ≤ N ≤ 100). The second line contains N integers representing the array C[1..N], where each value is a natural number not exceeding 10000.
Output data: Output the total cost of the purchase in standard monetary format.
Examples
Input #1
Answer #1
Submissions 769
Acceptance rate 15%