P5940 [CF1170F] Wheels
普及
题目描述

Polycarp has $n$ wheels and a car with $m$ slots for wheels. The initial pressure in the $i$-th wheel is $a_i$.

Polycarp's goal is to take exactly $m$ wheels among the given $n$ wheels and equalize the pressure in them (then he can put these wheels in a car and use it for driving). In one minute he can decrease or increase the pressure in any (single) wheel by $1$. He can increase the pressure no more than $k$ times in total because it is hard to pump up wheels.

Help Polycarp and say what is the minimum number of minutes he needs to spend to equalize the pressure of at least $m$ wheels among the given $n$ wheels.

Input

The first line of the input contains three integers $n, m$ and $k$ ($1 \le m \le n \le 2 \cdot 10^5, 0 \le k \le 10^9$) — the number of wheels, the number of slots for wheels in a car and the number of times Polycarp can increase by $1$ the pressure in a wheel.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is the pressure in the $i$-th wheel.

Output

Print one integer — the minimum number of minutes Polycarp needs to spend to equalize the pressure in at least $m$ wheels among the given $n$ wheels.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
6 6 7 6 15 16 20 1 5
样例输出
39