Problem: 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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> ma(N),mi(N);
  for(int i=0;i<N;i++){
    ma[i]=max(i,v[i]);
    mi[i]=min(i,v[i]);
  }
  sort(ma.begin(),ma.end());
  sort(mi.rbegin(),mi.rend());
  int ans=0;
  for(int i=0;i<N;i++)ans+=abs(i-v[i]);
  for(int i=0;i<M;i++)ans+=2*max(mi[i]-ma[i],0LL);
  cout<<ans<<endl;
}