import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

N abs(N)(N a) {
  return a * (a < 0 ? -1 : 1);
}

void main() {
  long N = readln.chomp.to!long;
  long[] A = readln.chomp.split.to!(long[]);
  A.sort!"a<b";
  long[] B = new long[](N);
  long ans;

  foreach (long i, a; A) {
    B[i] = a - (i + 1);
  }
  long b = B[N/2];

  foreach (e; B) {
    ans += abs(e - b);
  }

  writeln(ans);
}
