function Main(s){
  s = s.split("\n");
  var n = +s[0];
  var a = s[1].split(" ").map(a=>+a);
  var k = 0;
  for(var i = 0; i < n; i++){
    a[i] -= i + 1;
    k += a[i];
  }
  k = Math.floor(k / n);
  var x = 0, y = 0;
  for(i = 0; i < n; i++){
    x += Math.abs(a[i] - k);
    y += Math.abs(a[i] - k - 1);
  }
  console.log(Math.min(x,y));
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));