Preparando MOJI
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the group for $$$n$$$ days. On the $$$i$$$-th day:
Boboniu's mood is a constant $$$m$$$. On the $$$i$$$-th day:
The total fun factor is the sum of the fun factors on the days when Du can speak.
Du asked you to find the maximum total fun factor among all possible permutations of $$$a$$$.
The first line contains three integers $$$n$$$, $$$d$$$ and $$$m$$$ ($$$1\le d\le n\le 10^5,0\le m\le 10^9$$$).
The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots,a_n$$$ ($$$0\le a_i\le 10^9$$$).
Print one integer: the maximum total fun factor among all permutations of $$$a$$$.
5 2 11 8 10 15 23 5
48
20 2 16 20 5 8 2 18 16 2 16 16 1 5 16 2 13 6 16 4 17 21 7
195
In the first example, you can set $$$a'=[15, 5, 8, 10, 23]$$$. Then Du's chatting record will be:
Thus the total fun factor is $$$48$$$.