import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long test () {
  int n;
  readf (" %d", &n);
  if (n == 1) return 0;
  auto a = new int[n];
  foreach (t; 0 .. n) {
    readf (" %d", &a[t]);
  }
  //y = x
  //1 * x - y = 0
  auto d = new Tuple!(int,int)[n];
  foreach (i; 0 .. n) {
    d[i] = tuple ((i + 1) - a[i], i);
  }
  long res = long.max;
  
  long f (int i) {
    topN (d, i);
    immutable w = d[i][0];// + (d[i][1] + 1);
    long r;
    foreach (k; 0 .. n) {
      r += abs ( (k + 1) - a[k] - w); 
    }
    return r;
  }
  if (n & 1) {
    return f (n >> 1);
  } else {
    immutable m = n >> 1;
    return min (f (m - 1), f (m));
  }
}

void main() {
  writeln (test ());
}
