'use strict'
const main = (chunk => {
  const eachSad = (c, i) => c - i - 1
  const sad = (arr, diff, b) => arr.reduce((acc, c, i) => acc + Math.abs(diff[i] - b), 0)
  const diffs = arr => arr.map((e, i) => eachSad(e, i))
  const median = arr => arr[Math.floor(arr.length / 2)]

  return (chunk) => {
    const stack = chunk.split('\n')
    const array = stack[1].split(' ').map(e => parseInt(e, 10))
    const diff = diffs(array)
    const med = median(diff)
    const sadness = sad(array, diff, med);
    console.log(sadness)
  }
})()

process.stdin.setEncoding('utf-8')
process.stdin.on('data', chunk => main(chunk))
