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);
}

bool chmin(t)(ref t a, t b) {
  if (b < a) {
    a = b;
    return true;
  } else {
    return false;
  }
}

void main() {
  long N = readln.chomp.to!long;
  long[] A = readln.chomp.split.to!(long[]);
  long b = long.max;

  long[] C = new long[](N);

  foreach (long i, a; A) {
    long t = (a - (i + 1));
    C[i] = t;
    chmin(b, t);
  }

  long ans;

  foreach (c; C) {
    ans += abs(c - b);
  }

  writeln(ans);
}
