We’re preparing your current view and syncing the latest data.
The problem involves n items, each with an integer price which can be positive or negative. You can buy up to m items. The goal is to maximize the discount obtained. Since discount is gained by buying items with negative prices, the strategy is to choose the m items with the smallest (most negative) prices. The output is the total discount you can get, which is the absolute sum of chosen negative prices (sum negated).
The first line contains two integers n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ n). The second line contains n integers representing the prices of each item.
Output a single integer which is the maximum discount achievable.
1 ≤ n ≤ 100, 1 ≤ m ≤ n, item prices can be negative or positive integers within a reasonable range (e.g., -10^4 to 10^4).
Example 1
Input
6 3 -6 0 35 -2 4 -6
Output
14
Explanation
Choose the three most negative prices: -6, -6, -2. The total discount is |-6| + |-6| + |-2| = 14.