problem

Given a sequence $ A $ of length $ N $. You can swap the $ i $ th and $ j $ th ($ 0 \ leq i, j \ leq N-1 $) elements of a sequence up to $ M $ times.

Find the maximum value of $ \ sum_ {i = 0} ^ {N -1} abs (A_i --i) $ in the sequence created by the operation.



output

Find the maximum value of $ \ sum_ {i = 0} ^ {N --1} abs (A_i --i) $ in the sequence created by the operation. Also, output a line feed at the end.

Example

Input

5 2
0 3 2 1 4


Output

12
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> ub(N), lb(N);
    int64_t ans = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        ub[i] = max(a, i);
        lb[i] = min(a, i);
        ans += abs(a-i);
    }
    sort(ub.begin(), ub.end());
    sort(lb.rbegin(), lb.rend());
    for(int i=0; i<M; i++) ans += 2 * max(0, lb[i] - ub[i]);
    cout << ans << endl;
}

