import Data.Array.IArray(Array,listArray,(!))
import Data.List(sort)
-- after editorial
main = do
    n <- readLn
    ai <- fmap read . words <$> getLine
    let bi = zipWith (-) ai (iterate (+1) 1)
    let bi' = listArray (1,n) $ sort bi :: Array Int Int
    let b = bi'!(1+div n 2)
    print $ sum $ fmap (abs.subtract b) bi