#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
void pV(vector<long long> A) {
  cout << "[vector]";
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " ";
  }
  cout << endl;
}
int N;
vector<long long> B;
long long calcSum(long long d) {
  long long sum = 0;
  for (int i = (0); i < (N); ++i) {
    if (B[i] < d) {
      sum += (d - B[i]);
    } else if (B[i] > d) {
      sum += B[i] - d;
    }
  }
  return sum;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  vector<long long> A(N);
  for (int i = (0); i < (N); ++i) {
    cin >> A.at(i);
  }
  B.reserve(N);
  for (int i = (0); i < (N); ++i) {
    long long b = A[i] - i;
    B.push_back(b);
  }
  sort((B).begin(), (B).end());
  if (B.size() % 2 == 1) {
    int center = B.size() / 2;
    long long median = B[center];
    long long sum = calcSum(median);
    cout << (sum) << endl;
  } else {
    int center0 = B.size() / 2;
    int center1 = center0 - 1;
    long long median0 = B[center0];
    long long median1 = B[center1];
    long long sum0 = calcSum(median0);
    long long sum1 = calcSum(median1);
    cout << (min(sum0, sum1)) << endl;
  }
  return 0;
}
