
'use strict'

function Main(input) {
  const N = Number(input.split('\n')[0]);
  const line = input.split('\n')[1].split(' ').map(x => Number(x));

  let list = [];
  let dif = 0;
  let difmin1 = 999999999999999;
  let difmin2 = 999999999999999;

  for(let i=0; i<N; i++) {
    list.push(i+1);
  }

  let list1 = list;
  let list2 = list;

  for(let k=0; k<1000000000000; k++){
    for(let j=0; j<N; j++) {
      dif += Math.abs(line[j] - list1[j]);
    }
    if(difmin1 > dif) {
      difmin1 = dif;
      dif = 0;
    } else if (difmin1 < dif) {
      dif = 0;
      break;
    }
    list1 = list1.map(x => x+1);
  }


  for(let l=0; l<1000000000000; l++){
    for(let m=0; m<N; m++) {
      dif += Math.abs(line[m] - list2[m]);
    }
    if(difmin2 > dif) {
      difmin2 = dif;
      dif = 0;
    } else if (difmin2 < dif) {
      dif = 0;
      break;
    }
    list2 = list2.map(x => x-1);
  }

  console.log(Math.min(difmin1, difmin2));

}

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