#arc163b. [arc163_b]Favorite Game

[arc163_b]Favorite Game

Problem Statement

You are given an integer sequence of length NN: A=(A1,A2,dots,AN)A=(A_1,A_2,\\dots,A_N). You can perform the following operation any number of times (possibly zero).

  • Choose an integer ii such that 1leileN1 \\le i \\le N, and increase or decrease AiA_i by 11.

Your goal is to make at least MM integers i(3leileN)i(3 \\le i \\le N) satisfy A1leAileA2A_1 \\le A_i \\le A_2. Find the minimum number of operations required to achieve this goal.

Constraints

  • 3leNle2times1053 \\le N \\le 2 \\times 10^5
  • 1leMleN21 \\le M \\le N-2
  • 1leAile1091 \\le A_i \\le 10^9

Input

The input is given from Standard Input in the following format:

NN MM A1A_1 A2A_2 dots\\dots ANA_N

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 i(3leileN)i(3 \\le i \\le N) satisfy A1leAileA2A_1 \\le A_i \\le A_2 by performing the operation as follows.

  • Choose i=3i=3, and decrease AiA_i by 11.
  • Choose i=2i=2, and increase AiA_i by 11.

Since it is impossible to achieve the goal with less than 22 operation, the answer is 22.


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