object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val As = Array.tabulate(N)(i => in.nextLong - i - 1).sorted
  val median = if (N % 2 == 0) (As(N / 2 - 1) + As(N / 2)) / 2 else As(N / 2)
  println(As.map(i => math.abs(i - median)).sum)
}