#include <bits/stdc++.h>

using namespace std;

int main(){
  int n;
  cin >> n;
  long long sum = 0;
  int a[n];
  int b[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = a[i] - (i+1);
  }
  sort(b,b+n);
  long long ans = 0;
  for(int i = 0; i < n; i++){
    ans += abs(a[i] - (b[n/2] + i+1) );
  }
  cout << ans << endl;
  return 0;
}
