#arc163b. [arc163_b]Favorite Game
[arc163_b]Favorite Game
Problem Statement
You are given an integer sequence of length : . You can perform the following operation any number of times (possibly zero).
- Choose an integer such that , and increase or decrease by .
Your goal is to make at least integers satisfy . Find the minimum number of operations required to achieve this goal.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the minimum number of operations required.
Sample Input 1
3 1
2 3 5
Sample Output 1
2
You can make not less than one integer satisfy by performing the operation as follows.
- Choose , and decrease by .
- Choose , and increase by .
Since it is impossible to achieve the goal with less than operation, the answer is .
Sample Input 2
5 2
1 4 2 3 5
Sample Output 2
0
You may already have achieved the goal from the start.
Sample Input 3
8 5
15 59 64 96 31 17 88 9
Sample Output 3
35