F: Absum
Problem
You are given a sequence $A$ of length $N$. You can perform at most $M$ operations to swap the $i$-th and $j$-th ($0 \leq i, j \leq N-1$) elements of the sequence.
Find the maximum possible value of $\sum_{i = 0}^{N - 1} abs(A_i - i)$ over all possible sequences that can be obtained by performing the operations.
Constraints
$2 \leq N \leq 10^5$
$0 \leq M \leq N$
$0 \leq A_i \leq 10^5$
Input format
The input is given in the following format:
$N\ M$
$A_0\ A_1\ A_2\ \dots\ A_{N - 1}$
Output format
Print the maximum value of $\sum_{i = 0}^{N - 1} abs(A_i - i)$ over all possible sequences that can be obtained by performing the operations. Print a newline character at the end.
Sample Input 1
5 2
0 3 2 1 4
Sample Output 1
12
Swap the $0$-th and $4$-th elements to obtain the sequence $(4, 3, 2, 1, 0)$. The maximum value of $\sum_{i = 0}^{N - 1} abs(A_i - i)$ is $|4 - 0| + |3 - 1| + |2 - 2| + |1 - 3| + |0 - 4| = 12$. Note that it is not necessary to perform exactly $M$ operations.
Sample Input 2
3 2
0 0 0
Sample Output 2
3
The maximum value is obtained without performing any operations.
Sample Input 3
6 2
1 0 3 6 5 4
Sample Output 3
20
