object Main extends App {
  val n = readInt
  val nums = readLine.split(" ").map(_.toInt)
  val b = (nums.sum - ((n * (n + 1)) / 2)) / n.toDouble
  val min =nums.zipWithIndex.map{ case (a, i) => math.abs(a - (b + i + 1)) }.sum.toInt
  println(min)
}
