var lines = require("fs").readFileSync("/dev/stdin","utf-8").split("\n");
var N = parseInt(lines[0]);
var A = lines[1].split(" ").map((item)=>parseInt(item));
A=A.map((item,i)=>item-i);
var answer = Infinity;
var increment=Math.pow(10,9);
while(N%increment!==N){
  increment/=10;
}

var prev=Infinity;
var b = Math.min(...A);
var flag=true;
while(flag){
  var sum=0;
  for(var i=0;i<N;i++){
	var abs = Math.abs(A[i]-b);
    sum+=abs;
  }
  if(sum<answer)answer = sum;
  if(increment!==1 && sum>prev){
    b-=increment;
    increment/=10;
  }else if(increment===1 && b+increment>Math.max(...A)){
    flag=false;
  }else{
 	prev=sum;
  	b+=increment;
  }
}

console.log(answer);