'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = Number(input.shift())
  input = input[0].split(' ').map(n => Number(n))
  let ave = 0
  for (let i = 0; i < N; i++) {
    ave += input[i] - i - 1
  }
  ave = Math.floor(ave / N)
  let ans = 0
  for (let i = 0; i < N; i++) {
    ans += Math.abs(input[i] - i - 1 - ave)
  }
  console.log(ans)
}

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