#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n=int(input());a=sorted(int(x)-i for i,x in enumerate(input().split()));print(sum(abs(i-a[n//2])for i in a))\n"
"\"";
  system(s);
  return 0;
}            