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"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr ,greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,0 }, dy[] = { 1,0,-1,0,0 };
const int SIZE1 =3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 22;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y,H,W,Q;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE3][SIZE3], answer = zero;
LL A[SIZE], B[SIZE];
bool isBigger[SIZE];
LL solve() {
	cin >> N >> M;
	Vpr v;
	REP(i, N) {
		cin >> A[i];
		v.pb(A[i],i);
	}
	Vpr vb[2];
	sort(ALL(v), greater<pr>());
	REP(i, N) {
		if (v[i].first > i) isBigger[v[i].second] = true;
		LL potential = v[i].second;
		if (isBigger[v[i].second]) potential *= -1;
		if ((v[i].first > i) ^ (v[i].first > v[i].second)) {
			potential += abs(v[i].first - v[i].second);
		}
		vb[isBigger[v[i].second]].pb(potential,v[i].second);
	}
	//outputVI(vb[0]);
	//outputVI(vb[1]);
	sort(ALL(vb[0]));
	sort(ALL(vb[1]));
	LL ans = 0;
	REP(i, N) ans += abs(A[i] - i);
	LL maxim = ans;
	MN(M, min<LL>(vb[1].size(), vb[0].size()));
	REP(i, M) {
		LL a = vb[0][i].second;
		LL b = vb[1][i].second;
		ans -= abs(a - A[a]) + abs(b - A[b]);
		swap(vb[0][i], vb[1][i]);
		ans += abs(a - A[b]) + abs(b - A[a]);
		MX(maxim, ans);
	}
	cout << maxim << endl;
	return 0;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	solve();
//	cin >> N;
	return 0;
}
