#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  long long int a;
  long long int c[200000];
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a;
    c[i] = a - i - 1;
  }
  sort(c, c + n);
  long long int count = 0;
  for(int i = 0;i < (n / 2);i++){
    count += (c[n - i - 1] - c[i]);
  }
  cout << count << endl;
}
