object Main extends App {
  def abs(n: Int): Int = if (n >= 0) n else -n

  def mkObjectList(i: Int, A: List[Int], B: List[Int]): List[Int] =
    if (A.isEmpty) B.sorted
    else mkObjectList(i + 1, A.tail, (A.head - i) :: B)

  def computeSadness(B: List[Int], b: Int, res: Int): Int =
    if (B.isEmpty) res
    else computeSadness(B.tail, b, res + abs(B.head - b))

  val N = io.StdIn.readInt()
  val A = io.StdIn.readLine().split(" ").map(_.toInt).toList
  val B = mkObjectList(1, A, List())
  println(computeSadness(B, B.apply(N / 2), 0))
}
