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 <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    long long res = 0;
    vector<long long> plus, minus;
    for (int i = 0; i < N; ++i) {
        res += abs(a[i] - i);
        if (a[i] >= i) plus.push_back(a[i]), minus.push_back(i);
        else plus.push_back(i), minus.push_back(a[i]);
    }
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end(), greater<long long>());

    for (int i = 0; i < M; ++i) {
        if (plus[i] < minus[i]) {
            res += (minus[i] - plus[i]) * 2;
        }
        else {
            break;
        }
    }
    cout << res << endl;
}       

