var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var n = toInt(input[0]);
	var as = toIntArr(input[1].split(' '));
	var bs = [];
	for(var i = 0; i < n; i++){
		bs[i] = as[i] - i - 1;
	}
	var cs = bs.sort(function(a,b){return a-b});
	function abs(a){
		return a>0? a: -a;
	}
	function sum(b,array){
		var sums = 0;
		for(var j = 0;j<n;j++){
			sums += abs(array[j] - b);
		}
		return sums
	}
	var ans = sum(cs[0],cs);
	var alt = 0;
	for(var k = 1; k < n; k++){
		alt = sum(cs[k],cs);
		if(ans > alt) ans = alt;
	}

	console.log(ans);
}