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 "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> M;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	long long int ans = 0;
	for (int i = 0; i < N; i++)ans += abs(v[i] - i);
	vector<long long int>add(N);
	vector<long long int>minus(N);
	for (int i = 0; i < N; i++) {
		add[i] = min((long long int)i, v[i]) * 2;
		minus[i] = max((long long int)i, v[i]) * 2;
	}
	sort(add.begin(), add.end(), greater<long long int>());
	sort(minus.begin(), minus.end());
	long long int by = 0;
	for (int i = 0; i < M; i++) {
		if (add[i] - minus[i] < 0)continue;
		by += add[i];
		by -= minus[i];
	}
	cout << ans + by << endl;
	return 0;
}

