Given a list of prices, determine the minimum total cost after applying the usual discount rule to the cheapest item in each selected pair/grouping.
You are given prices of items in a shop. The task is to compute the minimum amount of money needed to buy all items when the shop applies a discount rule: among the items considered together, the cheapest one becomes free or gets the required discount according to the problem's sale logic.
For this problem, think of the key idea as identifying the cheapest eligible item(s) after sorting the prices and applying the discount rule to the items that matter. The goal is to produce the final total cost after the sale is applied to the full list.
Example 1
Input
5 5 1 3 4 2
Output
10
Explanation
After arranging the prices, apply the sale rule to the cheapest eligible items and sum the remaining paid prices.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.