object Main extends App {
	val n = scala.io.StdIn.readInt
	var a = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	for(i<-0 until n){
		a(i) -= i.toLong + 1L
	}

//	println(a.mkString(" "))

	a = a.sorted

	var ans = 0L

	val t = n/2

	if(n%2 == 1){
		val b = a(t)

		for(x<-a){
			ans += math.abs(x - b)
		}
		println(ans)

	}else{
		val b1 = a(t)
		val b2 = a(t-1)

		var ans1 = 0L

		for(x<-a){
			ans += math.abs(x - b1)
			ans1 += math.abs(x - b2)
		}
		println(math.min(ans, ans1))
	}
}
