"use strict";

function main(input) {
  var lines = input.split('\n');
  var N = parseInt(lines[0]);
  var as = splitNum(lines[1]).slice(0, N);
  var ads = as.map(function (a, i) {
    return a - i - 1;
  });
  ads.sort(function (a, b) {
    return a - b;
  });
  var med = ads[Math.floor(ads.length / 2)];
  var min = ads.map(function (ad) {
    return Math.abs(ad - med);
  }).reduce(function (a, b) {
    return a + b;
  }, 0);
  console.log(min);
}

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

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}
