#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long int ll;
int main(){
int n;
cin >>n;
ll a[n];
for(int i=0;i<n;i++) {
  cin >>a[i];
  a[i]-=(i+1);
}
sort(a,a+n);
ll ans=0,m;
if(n%2==0) m=(a[n/2]+a[n/2-1])/2;
else m=a[n/2];
for(int i=0;i<n;i++){
 ans+=abs(a[i]-m);
}
cout <<ans<<endl;
}
