#include <bits/stdc++.h>
const bool debug = false;
using namespace std;
const long long MOD = 1000000007;
int main(void) {
  long long n;
  cin >> n;
  long long a[n];
  long long sum = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> a[i];
    a[i] -= i + 1;
    sum += a[i];
  }
  long long val = sum / n;
  long long res = 1LL << 60, tmp = 0;
  for (int j = -1; j <= 1; j++) {
    tmp = 0;
    for (int(i) = 0; (i) < (n); (i)++) {
      tmp += abs(a[i] - val + j);
    }
    if (debug == true) {
      cout << tmp << endl;
    }
    if (res > tmp) res = tmp;
  }
  cout << res << endl;
  return 0;
}
