'use strict';
const inputRaw = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
const INPUT_LIST_LENGTH_INDEX = 0;
const INPUT_LIST_INDEX = 1;
const INPUT_LIST_DELIMITER = " ";
const inputListLength = parseInt(inputRaw[INPUT_LIST_LENGTH_INDEX]);
const inputList = inputRaw[INPUT_LIST_INDEX].split(INPUT_LIST_DELIMITER);

const process = (inputList, inputListLength) => {
  // pattern: min(b) in (sum(A-b)) === median of sorted A

  // sum(A - (b + i)) === sum ((A - i) - b)
  // convert list to A-i
  for (let i=0;i<inputListLength;i++) {
    inputList[i] = parseInt(inputList[i])-i;
  }

  const median = inputList[Math.floor(inputListLength/2)];

  return inputList.reduce((acc, currentItem) => acc + Math.abs(currentItem-median), 0);
}

console.log(process(inputList, inputListLength));