'use strict'

function main(s) {
  s = s.split('\n');

  const n = Number(s[0]);
  const a = s[1].split(' ');

  const absArr = [];
  for (let i = 0; i < n; i++) {
    absArr[i] = a[i] - (i + 1);
  }

  absArr.sort((a, b) => a - b);

  const med = n / 2;
  let b = 0;
  let ans = 0;

  if (n === 1) {
    b = absArr[0];
  } else {
    if (n % 2 === 0) {
      b = (absArr[med] + absArr[med - 1]) / 2;
    } else {
      b = (absArr[Math.floor(med)]);
    }
  }

  ans = absArr.reduce((acc, val) => acc + Math.abs(val - b), 0);
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
