Special Deal
There’s a special deal on CodeAny platform: “Select video courses, pay for the most expensive ones.” This means that for every set of courses chosen, the cheapest one is free. Customers can choose more than courses, and depending on how they organize them into groups of three, they can get the cheapest course in each group for free.
For instance, if a customer selects courses with prices: and , and arranges them into groups like , and , they’ll receive the course priced at from the first group, and the course priced at from the second group for free. The third group won’t yield any free courses because it contains only one course.
The employee on CodeAny platform aims to minimize the total cost for each customer. Given the course prices, the task is to assist the employee in organizing the courses into groups in the most cost-effective way possible. It’s not necessary for each group to contain exactly courses, but the number of courses in a group must range from to , inclusive.
Input
The first line contains the integer , the number of video courses the customer bought.
Each of the following lines contains a single integer , the price of each video course.
Output
Print required minimum price.
Examples
Scoring
This task consists of the following subtasks. If all tests of a subtask are passed, you will earn points for that subtask.
( points): ;
( points): ;