#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n],dist[n],cnt[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		dist[i] = a[i] - (i+1);
	}
	sort(dist,dist + n);
	int p = (dist[n/2]+dist[(n-1)/2])/2;
	long long ans = 0;
	for(int i=0;i<n;i++){
//		ans += abs(a[i] - (p + (i+1)));
		ans += abs(dist[i]-p);
	}

	cout << ans << endl;

}
