#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)

using ll = long long;

int N;
ll A[200005];
 
int main() {
  
  cin>>N;
  rep(i, N) {
    cin>>A[i];
    A[i] -= i+1;
  }
  
  sort(A, A+N);
  
  ll b = A[N/2];
  
  ll ans = 0;
  rep(i, N)ans += abs(A[i]-b);
  
  cout<<ans<<endl;
  
  return 0;
}
