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;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,m;
int a[125252];

int calc(int i, int j){
  return (abs(a[j]-i) + abs(a[i]-j)) - (abs(a[i]-i) + abs(a[j]-j));
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n)scanf("%d",a+i);
  ll ans = 0;
  REP(i,n)ans += abs(a[i]-i);
  set<pii> S[5];
  REP(i,n){
    if(a[i]<=i){
      S[1].insert(pii(a[i],i));
      S[2].insert(pii(i,a[i]));
    }else{
      S[3].insert(pii(i,a[i]));
      S[4].insert(pii(a[i],i));
    }
  }
  while(m--){
    pii sp = pii(-1,-1);
    int mxgain = -1;
    FOR(i,1,4+1)if(S[i].size()){
      pii P;
      int id;
      if(i==1){
        P = *S[i].rbegin();
        id = P.second;
      }else if(i==2){
        P = *S[i].begin();
        id = P.first;
      }else if(i==3){
        P = *S[i].rbegin();
        id = P.first;
      }else{
        P = *S[i].begin();
        id = P.second;
      }
      S[i].erase(P);
      FOR(j,1,4+1)if(S[j].size()){
        int id2;
        if(j==1)id2 = S[j].rbegin()->second;
        else if(j==2)id2 = S[j].begin()->first;
        else if(j==3)id2 = S[j].rbegin()->first;
        else if(j==4)id2 = S[j].begin()->second;
        int g = calc(id,id2);
        if(g > mxgain){
          mxgain = g;
          sp = pii(id,id2);
        }
      }
      S[i].insert(P);
    }
    if(mxgain == -1)break;
    ans += mxgain;
    {
      int i = sp.first;
      if(a[i]<=i){
        S[1].erase(pii(a[i],i));
        S[2].erase(pii(i,a[i]));
      }else{
        S[3].erase(pii(i,a[i]));
        S[4].erase(pii(a[i],i));
      }
      i = sp.second;
      if(a[i]<=i){
        S[1].erase(pii(a[i],i));
        S[2].erase(pii(i,a[i]));
      }else{
        S[3].erase(pii(i,a[i]));
        S[4].erase(pii(a[i],i));
      }
    }
    swap(a[sp.first],a[sp.second]);
    {
      int i = sp.first;
      if(a[i]<=i){
        S[1].insert(pii(a[i],i));
        S[2].insert(pii(i,a[i]));
      }else{
        S[3].insert(pii(i,a[i]));
        S[4].insert(pii(a[i],i));
      }
      i = sp.second;
      if(a[i]<=i){
        S[1].insert(pii(a[i],i));
        S[2].insert(pii(i,a[i]));
      }else{
        S[3].insert(pii(i,a[i]));
        S[4].insert(pii(a[i],i));
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}

