Problem D
Shopaholic
Lindsay is a shopaholic. Whenever there is a discount of the kind where you can buy three items and only pay for two, she goes completely mad and feels a need to buy all items in the store. You have given up on curing her for this disease, but try to limit its effect on her wallet.
You have realized that the stores coming with these offers
are quite selective when it comes to which items you get for
free; it is always the cheapest ones. As an example, when your
friend comes to the counter with seven items, costing
Your job is to find the maximum discount Lindsay can get.
Input
The first line of input gives the number of items Lindsay is
buying,
Output
Output one line giving the maximum discount Lindsay can get by selectively choosing which items she brings to the counter at the same time.
Sample Input 1 | Sample Output 1 |
---|---|
6 400 100 200 350 300 250 |
400 |