stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cmath>

using namespace std;

int main(){

	long long n,a[200000],i,z=0;

	cin>>n;

	for(i=0;i<n;i++){

		cin>>a[i];

		a[i]-=i;

	}

	sort(a,a+n);

	for(i=0;i<n;i++){

		z+=abs(a[n/2]-a[i]);

	}

	cout<<z;

}

// Faster C++ solution for the same problem (measured speedup: 5.396027313131784x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long LL;

const int maxn=2e5+100;

int n;

LL a[maxn];



int main()

{

    while (scanf("%d",&n)!=EOF)

    {

        for (int i=1;i<=n;i++)

        {

            scanf("%lld",&a[i]);

            a[i]-=i;

        }

        sort(a+1,a+n+1);

        LL ans1=0,ans2=0;

        for (int i=1;i<=n;i++)

        {

            ans1+=abs(a[i]-a[n/2]);

            ans2+=abs(a[i]-a[n/2+1]);

        }

        printf("%lld\n", min(ans1,ans2));

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<climits>

#include<algorithm>

#include<cmath>

#define LL long long 

using namespace std;

const int M=10e5;

LL a[2*M];

int  n;

int main()

{

	while(cin>>n)

	{

		for(int i=1;i<=n;++i)

		{

			scanf("%d",&a[i]),a[i]-=i;

		}

	    sort(a+1,a+n+1);

	    LL k;

	    if((n&1)==1)k=a[(n+1)/2];

	    else k=(a[n/2]+a[n/2+1])/2;

	    LL sum=0;

	    for(int i=1;i<=n;++i)

	    {

	    	sum+=abs(k-a[i]);

		}

		cout<<sum<<endl;

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.226018785054618x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long LL;

const int maxn=2e5+100;

int n;

LL a[maxn];



int main()

{

    while (scanf("%d",&n)!=EOF)

    {

        for (int i=1;i<=n;i++)

        {

            scanf("%lld",&a[i]);

            a[i]-=i;

        }

        sort(a+1,a+n+1);

        LL ans1=0,ans2=0;

        for (int i=1;i<=n;i++)

        {

            ans1+=abs(a[i]-a[n/2]);

            ans2+=abs(a[i]-a[n/2+1]);

        }

        printf("%lld\n", min(ans1,ans2));

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int N=200005;

int a[N],n,num;

long long  ans=0;

int main(){

    cin>>n;

    for(int i=1;i<=n;i++) 

		{

			cin>>a[i];

			a[i]-=i;

		}

    sort(a+1,a+n+1);

	num=a[(n+1)/2];

    for(int i=1;i<=n;i++) 

		ans+=abs(num-a[i]);

    cout<<ans<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.206596307604542x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long LL;

const int maxn=2e5+100;

int n;

LL a[maxn];



int main()

{

    while (scanf("%d",&n)!=EOF)

    {

        for (int i=1;i<=n;i++)

        {

            scanf("%lld",&a[i]);

            a[i]-=i;

        }

        sort(a+1,a+n+1);

        LL ans1=0,ans2=0;

        for (int i=1;i<=n;i++)

        {

            ans1+=abs(a[i]-a[n/2]);

            ans2+=abs(a[i]-a[n/2+1]);

        }

        printf("%lld\n", min(ans1,ans2));

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef int Int;

#define int long long

#define INF 0x3f3f3f3f

#define maxn 200005

int a[maxn];

map<int,int>vis;

Int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    int n;

    cin>>n;

    for(int i=1;i<=n;i++)

    {

        cin>>a[i];

        a[i]-=i;

        //cout<<a[i]<<' ';

        vis[a[i]]++;

    }

    //cout<<endl;

    sort(a+1,a+n+1);

    int sum=0;

    int tmp=1;

    int val=0;

    if(n%2)

    {

        val=a[(n+1)/2];

    }

    else

    {

        val = (a[n / 2 + 1] + a[n / 2]) / 2;

    }

   // cout<<val<<endl;

    for(int i=1;i<=n;i++)

    {

        sum+=abs(a[i]-val);

    }

    cout<<sum<<endl;   

     return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.285680397938126x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long LL;

const int maxn=2e5+100;

int n;

LL a[maxn];



int main()

{

    while (scanf("%d",&n)!=EOF)

    {

        for (int i=1;i<=n;i++)

        {

            scanf("%lld",&a[i]);

            a[i]-=i;

        }

        sort(a+1,a+n+1);

        LL ans1=0,ans2=0;

        for (int i=1;i<=n;i++)

        {

            ans1+=abs(a[i]-a[n/2]);

            ans2+=abs(a[i]-a[n/2+1]);

        }

        printf("%lld\n", min(ans1,ans2));

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<climits>

#include<algorithm>

#include<cmath>

#define LL long long 

using namespace std;

const int M=10e5;

LL a[2*M];

int  n;

int main()

{

	while(cin>>n)

	{

		for(int i=1;i<=n;++i)

		{

			scanf("%d",&a[i]),a[i]-=i;

		}

	    sort(a+1,a+n+1);

	    LL k;

	    if((n&1)==1)k=a[(n+1)/2];

	    else k=(a[n/2]+a[n/2+1])/2;

	    LL sum=0;

	    for(int i=1;i<=n;++i)

	    {

	    	sum+=abs(k-a[i]);

		}

		cout<<sum<<endl;

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.226075541882173x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long LL;

const int maxn=2e5+100;

int n;

LL a[maxn];



int main()

{

    while (scanf("%d",&n)!=EOF)

    {

        for (int i=1;i<=n;i++)

        {

            scanf("%lld",&a[i]);

            a[i]-=i;

        }

        sort(a+1,a+n+1);

        LL ans1=0,ans2=0;

        for (int i=1;i<=n;i++)

        {

            ans1+=abs(a[i]-a[n/2]);

            ans2+=abs(a[i]-a[n/2+1]);

        }

        printf("%lld\n", min(ans1,ans2));

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cmath>

using namespace std;

int main(){

	long long n,a[200000],i,z=0;

	cin>>n;

	for(i=0;i<n;i++){

		cin>>a[i];

		a[i]-=i;

	}

	sort(a,a+n);

	for(i=0;i<n;i++){

		z+=abs(a[n/2]-a[i]);

	}

	cout<<z;

}

// Faster C++ solution for the same problem (measured speedup: 5.40164795382466x):
//------(▼皿▼#) fxxk vjudge-------

#include <algorithm>

#include <cstdio>



const int Maxv = 200010; 



int num[Maxv], n; 

long long ans; 



int main() {

    scanf("%d", &n); 

    for (int i = 0; i < n; i++) {

        scanf("%d", &num[i]); 

        num[i] -= i + 1; 

    }

    

    std::sort(num, num + n); 

    int tmp = num[(n >> 1)]; 



    for (int i = 0; i < n; i++) 

        ans += abs(num[i] - tmp); 



    printf("%lld\n", ans); 



    return 0; 

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<climits>

#include<algorithm>

#include<cmath>

#define LL long long 

using namespace std;

const int M=10e5;

LL a[2*M];

int  n;

int main()

{

	while(cin>>n)

	{

		for(int i=1;i<=n;++i)

		{

			scanf("%d",&a[i]),a[i]-=i;

		}

	    sort(a+1,a+n+1);

	    LL k;

	    if((n&1)==1)k=a[(n+1)/2];

	    else k=(a[n/2]+a[n/2+1])/2;

	    LL sum=0;

	    for(int i=1;i<=n;++i)

	    {

	    	sum+=abs(k-a[i]);

		}

		cout<<sum<<endl;

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.231462340496513x):
//------(▼皿▼#) fxxk vjudge-------

#include <algorithm>

#include <cstdio>



const int Maxv = 200010; 



int num[Maxv], n; 

long long ans; 



int main() {

    scanf("%d", &n); 

    for (int i = 0; i < n; i++) {

        scanf("%d", &num[i]); 

        num[i] -= i + 1; 

    }

    

    std::sort(num, num + n); 

    int tmp = num[(n >> 1)]; 



    for (int i = 0; i < n; i++) 

        ans += abs(num[i] - tmp); 



    printf("%lld\n", ans); 



    return 0; 

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int N=200005;

int a[N],n,num;

long long  ans=0;

int main(){

    cin>>n;

    for(int i=1;i<=n;i++) 

		{

			cin>>a[i];

			a[i]-=i;

		}

    sort(a+1,a+n+1);

	num=a[(n+1)/2];

    for(int i=1;i<=n;i++) 

		ans+=abs(num-a[i]);

    cout<<ans<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.212019632094892x):
//------(▼皿▼#) fxxk vjudge-------

#include <algorithm>

#include <cstdio>



const int Maxv = 200010; 



int num[Maxv], n; 

long long ans; 



int main() {

    scanf("%d", &n); 

    for (int i = 0; i < n; i++) {

        scanf("%d", &num[i]); 

        num[i] -= i + 1; 

    }

    

    std::sort(num, num + n); 

    int tmp = num[(n >> 1)]; 



    for (int i = 0; i < n; i++) 

        ans += abs(num[i] - tmp); 



    printf("%lld\n", ans); 



    return 0; 

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef int Int;

#define int long long

#define INF 0x3f3f3f3f

#define maxn 200005

int a[maxn];

map<int,int>vis;

Int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    int n;

    cin>>n;

    for(int i=1;i<=n;i++)

    {

        cin>>a[i];

        a[i]-=i;

        //cout<<a[i]<<' ';

        vis[a[i]]++;

    }

    //cout<<endl;

    sort(a+1,a+n+1);

    int sum=0;

    int tmp=1;

    int val=0;

    if(n%2)

    {

        val=a[(n+1)/2];

    }

    else

    {

        val = (a[n / 2 + 1] + a[n / 2]) / 2;

    }

   // cout<<val<<endl;

    for(int i=1;i<=n;i++)

    {

        sum+=abs(a[i]-val);

    }

    cout<<sum<<endl;   

     return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.291186098448924x):
//------(▼皿▼#) fxxk vjudge-------

#include <algorithm>

#include <cstdio>



const int Maxv = 200010; 



int num[Maxv], n; 

long long ans; 



int main() {

    scanf("%d", &n); 

    for (int i = 0; i < n; i++) {

        scanf("%d", &num[i]); 

        num[i] -= i + 1; 

    }

    

    std::sort(num, num + n); 

    int tmp = num[(n >> 1)]; 



    for (int i = 0; i < n; i++) 

        ans += abs(num[i] - tmp); 



    printf("%lld\n", ans); 



    return 0; 

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<climits>

#include<algorithm>

#include<cmath>

#define LL long long 

using namespace std;

const int M=10e5;

LL a[2*M];

int  n;

int main()

{

	while(cin>>n)

	{

		for(int i=1;i<=n;++i)

		{

			scanf("%d",&a[i]),a[i]-=i;

		}

	    sort(a+1,a+n+1);

	    LL k;

	    if((n&1)==1)k=a[(n+1)/2];

	    else k=(a[n/2]+a[n/2+1])/2;

	    LL sum=0;

	    for(int i=1;i<=n;++i)

	    {

	    	sum+=abs(k-a[i]);

		}

		cout<<sum<<endl;

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.231519156443438x):
//------(▼皿▼#) fxxk vjudge-------

#include <algorithm>

#include <cstdio>



const int Maxv = 200010; 



int num[Maxv], n; 

long long ans; 



int main() {

    scanf("%d", &n); 

    for (int i = 0; i < n; i++) {

        scanf("%d", &num[i]); 

        num[i] -= i + 1; 

    }

    

    std::sort(num, num + n); 

    int tmp = num[(n >> 1)]; 



    for (int i = 0; i < n; i++) 

        ans += abs(num[i] - tmp); 



    printf("%lld\n", ans); 



    return 0; 

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

int main(){

	long long int a,b,i,d,res=0;

	

	cin>>a;

	vector<int> c(a);

	for(i=0;i<a;i++){

		cin>>c[i];

		c[i]-=i-100;

	}

	sort(c.begin(),c.end());

	b=c[a/2];

	for(i=0;i<a;i++)res+=abs(c[i]-b);

	cout<<res;

}

// Faster C++ solution for the same problem (measured speedup: 5.270471586927671x):
//------(▼皿▼#) fxxk vjudge-------

#include <algorithm>

#include <cstdio>



const int Maxv = 200010; 



int num[Maxv], n; 

long long ans; 



int main() {

    scanf("%d", &n); 

    for (int i = 0; i < n; i++) {

        scanf("%d", &num[i]); 

        num[i] -= i + 1; 

    }

    

    std::sort(num, num + n); 

    int tmp = num[(n >> 1)]; 



    for (int i = 0; i < n; i++) 

        ans += abs(num[i] - tmp); 



    printf("%lld\n", ans); 



    return 0; 

}
// Slower C++ solution:
////#include <bits/stdc++.h>

//#include <iostream>

//#include <algorithm>

//using namespace std;

//

//long long n,ans;

//int main() {

//    while(cin >> n) {

////          cout << __gcd(n,(long long)2) << endl;

//        if(__gcd((long long)2,n) == 1)

//            cout << (long long)2 * n << endl;

//        else {

//            cout << n << endl;

//

//        }

//    }

//    return 0;

//}

//#include <bits/stdc++.h>

//#include <iostream>

//#include <algorithm>

//using namespace std;

//

////long long n,ans;

//int n,x;

//int main() {

//    while(cin >> n) {

//            int Max = -99;

//            int Min = 2e9;

//            for(int i = 0;i < n;i++){

//                    cin >> x;

//                 Max = max(x,Max);

//                 Min = min(x,Min);

//            }

//            cout << Max - Min << endl;

//    }

//    return 0;

//}









#include <iostream>

#include <stdio.h>

#include <map>

#include <algorithm>

using namespace std;

const int Maxn = 2e5 + 100;

int n,x;

int a[Maxn];

map<int,int>m;

int main() {

    while(cin >> n) {

        m.clear();

        for(int i = 0; i < n; i++)

            cin >> a[i];

        long long  ans = 0;

        int b = 0;

        int q = 1;

        for(int i = 0; i < n; i++) {

            a[i] -= q++;

            m[a[i]]++;

        }

        sort(a,a + n);

        int cnt = 0;

        for(int i = 0; i < n; i++) {

            if(a[i] == 0) continue;

            if(m[a[i]] && m[-a[i]])

                cnt++,m[a[i]]--,m[-a[i]]--;

        }

        int Max = 0;

        int data;

        if(cnt == n) b = 0;

        else {

            b = a[n / 2];

//            for(map<int,int>::iterator it = m.begin(); it != m.end(); it++)  {

////                if(it -> first == 0) continue;

//                if(Max < it -> second) {

//                    Max = it -> second;

//                    data = it -> first;

//                }

            }

//            b = data;

//        }

//        cout << b <<endl;

        for(int i = 0; i < n; i++) {

            ans += abs(a[i] - b);

        }

        cout << ans << endl;

    }

    return 0;

}

 

// Faster C++ solution for the same problem (measured speedup: 5.244804439769433x):
#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

int n,a[200005],mid;

long long sum;

int main()

{

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%d",&a[i]);

		a[i]-=i;

	}

	sort(a,a+n);

	mid=a[n/2];

	for(int i=0;i<n;i++)sum+=abs(a[i]-mid);

	printf("%lld",sum);

}
// Slower C++ solution:
////#include <bits/stdc++.h>

//#include <iostream>

//#include <algorithm>

//using namespace std;

//

//long long n,ans;

//int main() {

//    while(cin >> n) {

////          cout << __gcd(n,(long long)2) << endl;

//        if(__gcd((long long)2,n) == 1)

//            cout << (long long)2 * n << endl;

//        else {

//            cout << n << endl;

//

//        }

//    }

//    return 0;

//}

//#include <bits/stdc++.h>

//#include <iostream>

//#include <algorithm>

//using namespace std;

//

////long long n,ans;

//int n,x;

//int main() {

//    while(cin >> n) {

//            int Max = -99;

//            int Min = 2e9;

//            for(int i = 0;i < n;i++){

//                    cin >> x;

//                 Max = max(x,Max);

//                 Min = min(x,Min);

//            }

//            cout << Max - Min << endl;

//    }

//    return 0;

//}









#include <iostream>

#include <stdio.h>

#include <map>

#include <algorithm>

using namespace std;

const int Maxn = 2e5 + 100;

int n,x;

int a[Maxn];

map<int,int>m;

int main() {

    while(cin >> n) {

        m.clear();

        for(int i = 0; i < n; i++)

            cin >> a[i];

        long long  ans = 0;

        int b = 0;

        int q = 1;

        for(int i = 0; i < n; i++) {

            a[i] -= q++;

            m[a[i]]++;

        }

        sort(a,a + n);

        int cnt = 0;

        for(int i = 0; i < n; i++) {

            if(a[i] == 0) continue;

            if(m[a[i]] && m[-a[i]])

                cnt++,m[a[i]]--,m[-a[i]]--;

        }

        int Max = 0;

        int data;

        if(cnt == n) b = 0;

        else {

            b = a[n / 2];

//            for(map<int,int>::iterator it = m.begin(); it != m.end(); it++)  {

////                if(it -> first == 0) continue;

//                if(Max < it -> second) {

//                    Max = it -> second;

//                    data = it -> first;

//                }

            }

//            b = data;

//        }

//        cout << b <<endl;

        for(int i = 0; i < n; i++) {

            ans += abs(a[i] - b);

        }

        cout << ans << endl;

    }

    return 0;

}

 

// Faster C++ solution for the same problem (measured speedup: 5.253403748836434x):
#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

long long N,a[200005],b[200005],zj,ans;

int main()

{

	scanf("%lld",&N);

	for(long long i=1;i<=N;i++)

	{

		scanf("%lld",&a[i]);

		b[i]=a[i];

		a[i]-=i;

	}

	sort(a+1,a+N+1);

	zj=a[N/2+1];

	for(long long i=1;i<=N;i++)

	ans+=abs(b[i]-i-zj);

	printf("%lld",ans);

	return 0;

}
// Slower C++ solution:
////#include <bits/stdc++.h>

//#include <iostream>

//#include <algorithm>

//using namespace std;

//

//long long n,ans;

//int main() {

//    while(cin >> n) {

////          cout << __gcd(n,(long long)2) << endl;

//        if(__gcd((long long)2,n) == 1)

//            cout << (long long)2 * n << endl;

//        else {

//            cout << n << endl;

//

//        }

//    }

//    return 0;

//}

//#include <bits/stdc++.h>

//#include <iostream>

//#include <algorithm>

//using namespace std;

//

////long long n,ans;

//int n,x;

//int main() {

//    while(cin >> n) {

//            int Max = -99;

//            int Min = 2e9;

//            for(int i = 0;i < n;i++){

//                    cin >> x;

//                 Max = max(x,Max);

//                 Min = min(x,Min);

//            }

//            cout << Max - Min << endl;

//    }

//    return 0;

//}









#include <iostream>

#include <stdio.h>

#include <map>

#include <algorithm>

using namespace std;

const int Maxn = 2e5 + 100;

int n,x;

int a[Maxn];

map<int,int>m;

int main() {

    while(cin >> n) {

        m.clear();

        for(int i = 0; i < n; i++)

            cin >> a[i];

        long long  ans = 0;

        int b = 0;

        int q = 1;

        for(int i = 0; i < n; i++) {

            a[i] -= q++;

            m[a[i]]++;

        }

        sort(a,a + n);

        int cnt = 0;

        for(int i = 0; i < n; i++) {

            if(a[i] == 0) continue;

            if(m[a[i]] && m[-a[i]])

                cnt++,m[a[i]]--,m[-a[i]]--;

        }

        int Max = 0;

        int data;

        if(cnt == n) b = 0;

        else {

            b = a[n / 2];

//            for(map<int,int>::iterator it = m.begin(); it != m.end(); it++)  {

////                if(it -> first == 0) continue;

//                if(Max < it -> second) {

//                    Max = it -> second;

//                    data = it -> first;

//                }

            }

//            b = data;

//        }

//        cout << b <<endl;

        for(int i = 0; i < n; i++) {

            ans += abs(a[i] - b);

        }

        cout << ans << endl;

    }

    return 0;

}

 

// Faster C++ solution for the same problem (measured speedup: 5.257083528310716x):
#include<cstdio>

#include<cmath>

#include<algorithm>

#include<cstring>

using namespace std;

long long n;

long long a[200005];

long long sum=0;

long long ans;

int main()

{

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)

	{

		scanf("%lld",&a[i]);

		a[i]-=i;

	}

	long long temp;

	if(n%2==1) temp=(n+1)/2;

	else temp=n/2; 

	sort(a+1,a+n+1);

	ans=a[temp];

	for(int i=1;i<=n;i++)

	{

		sum+=abs(ans-a[i]);

	}

	printf("%lld",sum);

}
// Slower C++ solution:
////#include <bits/stdc++.h>

//#include <iostream>

//#include <algorithm>

//using namespace std;

//

//long long n,ans;

//int main() {

//    while(cin >> n) {

////          cout << __gcd(n,(long long)2) << endl;

//        if(__gcd((long long)2,n) == 1)

//            cout << (long long)2 * n << endl;

//        else {

//            cout << n << endl;

//

//        }

//    }

//    return 0;

//}

//#include <bits/stdc++.h>

//#include <iostream>

//#include <algorithm>

//using namespace std;

//

////long long n,ans;

//int n,x;

//int main() {

//    while(cin >> n) {

//            int Max = -99;

//            int Min = 2e9;

//            for(int i = 0;i < n;i++){

//                    cin >> x;

//                 Max = max(x,Max);

//                 Min = min(x,Min);

//            }

//            cout << Max - Min << endl;

//    }

//    return 0;

//}









#include <iostream>

#include <stdio.h>

#include <map>

#include <algorithm>

using namespace std;

const int Maxn = 2e5 + 100;

int n,x;

int a[Maxn];

map<int,int>m;

int main() {

    while(cin >> n) {

        m.clear();

        for(int i = 0; i < n; i++)

            cin >> a[i];

        long long  ans = 0;

        int b = 0;

        int q = 1;

        for(int i = 0; i < n; i++) {

            a[i] -= q++;

            m[a[i]]++;

        }

        sort(a,a + n);

        int cnt = 0;

        for(int i = 0; i < n; i++) {

            if(a[i] == 0) continue;

            if(m[a[i]] && m[-a[i]])

                cnt++,m[a[i]]--,m[-a[i]]--;

        }

        int Max = 0;

        int data;

        if(cnt == n) b = 0;

        else {

            b = a[n / 2];

//            for(map<int,int>::iterator it = m.begin(); it != m.end(); it++)  {

////                if(it -> first == 0) continue;

//                if(Max < it -> second) {

//                    Max = it -> second;

//                    data = it -> first;

//                }

            }

//            b = data;

//        }

//        cout << b <<endl;

        for(int i = 0; i < n; i++) {

            ans += abs(a[i] - b);

        }

        cout << ans << endl;

    }

    return 0;

}

 

// Faster C++ solution for the same problem (measured speedup: 5.248242315238718x):
#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

typedef long long ll;

const int maxn = 2e5 + 7;

int a[maxn];

int main(){

    int n;

    scanf("%d", &n);

    for(int i = 1; i <= n; ++i){

        scanf("%d", &a[i]);

        a[i] -= i;

    }

    sort(a+1, a+1+n);

    ll sum = 0;

    for(int i = 1; i <= n; ++i){

        sum += abs(a[i] - a[(n+1)/2]);

    }

    printf("%lld\n", sum);

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



const int maxn = 2e5+7;



int main(int argc, char *argv[]) {  

	long long n, a[maxn];

	std::cin >> n;

	for (int i = 0; i < n; i++) {

		std::cin >> a[i];

		a[i] -= (i+1);

	}

	std::sort(a, a+n);

	long long b = a[(n)/2];

	long long ans = 0;

	for (int i = 0; i < n; i++) {

		ans += std::abs(a[i]-b);

	}

	std::cout << ans;

}

// Faster C++ solution for the same problem (measured speedup: 5.4114996963468185x):
#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

typedef long long ll;

const int maxn = 2e5 + 7;

int a[maxn];

int main(){

    int n;

    scanf("%d", &n);

    for(int i = 1; i <= n; ++i){

        scanf("%d", &a[i]);

        a[i] -= i;

    }

    sort(a+1, a+1+n);

    ll sum = 0;

    for(int i = 1; i <= n; ++i){

        sum += abs(a[i] - a[(n+1)/2]);

    }

    printf("%lld\n", sum);

}