import scala.math.abs

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
	val as = List.fill(n)(sc.nextInt)

    println(
      ((as.min - n) to (as.max + 1)).map(sadness(as, n, _)).min
    )
  }

  def sadness(as: List[Int], n: Int, b: Int) = (as zip (1 to n)).map(ak => abs(ak._1 - (b + ak._2))).sum
}
