import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ").map(_.toLong)
  val aind = a.zipWithIndex
  
  //val r = aind.map( ai => scala.math.abs(ai._1 - (ai._2 + 1)))
  val r = aind.map( ai => ai._1 - (ai._2 + 1))
  //println(r.mkString(" "))
  val m = r.groupBy( mi => mi).map( e => e._1 -> e._2.size)
  val k = m.foldLeft(m.head)((acc, mi) => if(acc._2 > mi._2) acc else mi)
  def solv(pd: Long) = aind.foldLeft(0L)( (acc ,ai) => acc + scala.math.abs(ai._1 - (pd + ai._2 + 1)))
  
  println(solv(k._1))
  
  //val mina = for(d <- ind) yield solv(pd)

  //println(mina.toList.mkString(" "))

  //println(mina.min)

}
