struct Heap<Element: Comparable> {
    var items = [Element]()
    mutating func push(item: Element) {
        var i = items.count
        while i > 0 {
            let p = (i - 1) / 2
            if items[p] <= item {
                break
            }
            if i == items.count {
                items.append(items[p])
            } else {
                items[i] = items[p]
            }
            i = p
        }
        if i == items.count {
            items.append(item)
        } else {
            items[i] = item
        }
    }
    var count: Int {
        return items.count
    }
    subscript(i: Int) -> Element {
        return items[i]
    }
}
let N = Int(readLine()!)!
var B = Heap<Int>()
readLine()!.characters.split(" ").enumerate().forEach{B.push(Int(String($0.1))!-$0.0+1)}
let b = B[N/2]
print((0..<N).reduce(0){B[$0]+abs($1-b)})