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>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,m;
ll a[100100];

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

  cin>>n>>m;
  rep(i,n)cin>>a[i];

  ll crt=0;
  vector<ll> pos,neg;
  rep(i,n){
    crt+=abs(a[i]-i);
    pos.push_back(max(a[i],i));
    neg.push_back(min(a[i],i));
  }
  sort(all(pos));
  sort(all(neg)); reverse(all(neg));

  rep(i,m)crt+=max(0LL,-pos[i]+neg[i])*2;
  cout<<crt<<endl;

  return 0;
}