An array $A$ of $n$ positive integers is given. Exactly $B$ times you pick a value $c$ and set every element equal to $c$ to $0$. After performing exactly $B$ operations, print the minimum possible sum of $A$. (Zeroing an already-absent value wastes an operation, so you can effectively remove up to the $B$ groups whose value-times-count contribution is largest.)
Input
First line $n$ and $B$ ($1 \le B \le n \le 300000$). Second line $A_1, \dots, A_n$ ($1 \le A_i \le 10^9$).
Output
Print the minimum possible sum.
Example 1
Input
10 2 1 1 1 1 1 7 2 2 3 4
Output
11
Example 2
Input
5 3 1 2 2 2 1
Output
0
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.