E. Edit Set
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output

You were gifted a set containing many different integers. As you find large sets too intimidating, you want to make it smaller. In order to achieve this, you are allowed to apply the following operations to it:

  • choose one element from the set and add $$$1$$$ to it
  • choose one element from the set and subtract $$$1$$$ from it
Note that as this is a set, when after an operation two elements would have the same value, only one of them stays in the set, decreasing its size by one.
Input

The first line contains two integers $$$n$$$, $$$k$$$ ($$$1 \leq k \leq n \leq 2\cdot10^5$$$), the initial size of the set and the size you want to reach. The next line contains $$$n$$$ distinct integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^9$$$), the numbers in the initial set.

Output

Output the minimal number of operations required to reduce the size of the set to $$$k$$$.

Examples
Input
5 4
8 4 6 1 10
Output
2
Input
4 2
1 8 3 9
Output
3
Input
4 1
11 4 12 7
Output
8
Input
3 3
1 5 4
Output
0
Note

For the first sample, we can choose $$$4$$$ from the set and increase it by one. Then the set becomes $$$\{8,5,6,1,10\}$$$. Then we can choose $$$6$$$ and decrease it by one. As 5 is already present in the set, the new set will look like $$$\{8,5,1,10\}$$$ and we are done. It can be shown that no sequence of operations with fewer than $$$2$$$ moves exists, which decreases the size of the set to $$$4$$$.

For the second sample, we can decrease $$$3$$$ two times in a row and increase $$$8$$$ once, ending up with the set $$$\{1,9\}$$$. No shorter move sequence exists.

For the third sample, we can increase $$$4$$$ to $$$7$$$, then decrease $$$12$$$ to $$$11$$$ and then increase $$$7$$$ to $$$11$$$ taking us $$$8$$$ moves in total. This can be proven to be optimal.