#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#include<algorithm>
using namespace std;
int n,a[220000],b;
long long ans;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	fo(i,1,n) a[i]-=i;
	sort(a+1,a+n+1);
	b=a[(n+1)>>1];
	fo(i,1,n) ans+=abs(b-a[i]);
	printf("%lld\n",ans);
	return 0;
}