#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int M=10e5,MN=INT_MAX/2;
int a[2*M],ans;
int  n;
int judge(int k)
{
	int sum_l=0,sum_m=0,sum_r=0;
	for(int i=1;i<=n;++i)
	{
		sum_l+=abs(k-1-a[i]);
		sum_m+=abs(k-a[i]);
		sum_r+=abs(k+1-a[i]);
	}
	if(ans>sum_m)ans=sum_m;
	if(sum_l<sum_m)return 1;
	else if(sum_r<sum_m) return 2;
	else return 0;
}
int main()
{
	int minn,maxx;
	while(cin>>n)
	{
		ans=minn=MN;
		maxx=-MN;
		for(int i=1;i<=n;++i)
		{
			scanf("%d",&a[i]),a[i]-=i;
			minn=min(minn,a[i]);
			maxx=max(maxx,a[i]);
		}
		int l,r,mid,flag;
		l=minn;
		r=maxx;
		while(l<=r)
		{
			mid=(l+r)/2;
		    flag=judge(mid);
		    if(mid>=0)
		    {
		    	 if(flag==0)break;
		         else if(flag==1) r=mid;
		         else l=mid+1;
			}
			else if(mid<0)
			{
				 if(flag==0)break;
		         else if(flag==1) r=mid-1;
		         else l=mid;
			}
		    if(l==r&&mid==r)break;
		}
		cout<<ans<<endl;
	}
}