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 F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;
bool p[2][100000];

signed main(){
  int n,m,a[100000],ans=0;
  vector<PP> v;

  cin>>n>>m;
  
  for(int i=0;i<n;i++){
    cin>>a[i];
    v.push_back(PP(P(a[i],i),P(i,0)));
    v.push_back(PP(P(i,a[i]),P(i,1)));
    ans+=abs(a[i]-i);
  }
  sort(v.begin(),v.end());

  for(int i=0;i<n;i++){
    int fi=v[i].second.first,se=v[i].second.second;
    p[se][fi]=1;
  }

  vector<int> x,y;
  for(int i=0;i<n;i++){
    if(p[0][i]&&p[1][i])y.push_back(max(a[i],i));
    if(!p[0][i]&&!p[1][i])x.push_back(min(a[i],i));
  }

  sort(x.begin(),x.end());
  reverse(x.begin(),x.end());
  sort(y.begin(),y.end());

  for(int i=0;i<min((int)x.size(),m);i++) ans+=(x[i]*2-y[i]*2);
  cout<<ans<<endl;  
  
  return 0;
}

