Score : $500$ points
Takahashi has come to an amusement park.
The park has $N$ attractions. The fun of the $i$-th attraction is initially $a_i$.
When Takahashi rides the $i$-th attraction, the following sequence of events happens.
Takahashi's satisfaction is initially $0$. He can ride the attractions at most $K$ times in total in any order.
What is the maximum possible value of satisfaction Takahashi can end up with?
Other than riding the attractions, nothing affects Takahashi's satisfaction.
Input is given from Standard Input in the following format:
$N$ $K$ $A_1$ $A_2$ $\dots$ $A_N$
Print the maximum possible value of satisfaction that Takahashi can end up with.
3 5 100 50 102
502
Takahashi should ride the first attraction twice and the third attraction three times.
He will end up with the satisfaction of $(100+99)+(102+101+100)=502$.
There is no way to get the satisfaction of $503$ or more, so the answer is $502$.
2 2021 2 3
9
Takahashi may choose to ride the attractions fewer than $K$ times in total.