import Data.List(sort)
-- after editorial
main = do
    n <- readLn
    ai <- (fmap read . words) <$> getLine
    let i = iterate (+1) 1
    let bi = sort $ zipWith (-) ai i
    let b = bi!!(div n 2)
    print $ foldl (+) 0 $ fmap abs $ zipWith (-) ai (iterate (+1) (b+1))
