var main = (function(input) {
  var eachSad = function (c, i) {
    return c - i - 1
  }
  var sad = function (arr, diff, b) {
    var sum = 0
    for (var i = 0; i < arr.length; i++) {
      sum += Math.abs(diff[i] - b)
    }
    return sum
  }
  var diffs = function (arr) {
    var tmp = []
    for (var i = 0; i < arr.length; i++) {
      tmp.push(eachSad(arr[i], i))
    }
    return tmp
  }
  var median = function (arr) {
    return arr[Math.floor(arr.length / 2)]
  }

  // let stack = []
  return function(input) {
    stack = input.split('\n')

    // stack.push(chunk.split(' ').map(e => parseInt(e, 10))) // Array
    var diff = diffs(stack[1])
    var med = median(diff)
    var sadness = sad(stack[1], diff, med);
    console.log(sadness)
  }
})()

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