// https://abc102.contest.atcoder.jp/tasks/arc100_a

function f(arr) {
  const newArr = arr.map((n, i) => n - (i + 1))
  const sum = newArr.reduce((acc, n) => acc + n, 0)
  const average = sum / newArr.length
  const b = Math.round(average)

  return arr.reduce((acc, n, i) => acc + Math.abs(n - (b + i + 1)), 0)
}

module.exports = {
  f,
}

function Main(input) {
  const lines = input.split("\n")
  // const n = parseInt(lines[0], 10)
  const arr = lines[1].split(" ").map(item => parseInt(item, 10))

  console.log(f(arr))
}

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