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