import Control.Applicative

main = do
    _ <- getLine
    ns <- map read.words <$> getLine :: IO [Int]
    putStrLn.show $ answer ns

answer ns = minimum $ map (f ns') [0..mx] where
    ns'= map (\(i,a) -> (i,a-i)) $ zip [1..] ns
    mx = maximum $ map (abs.snd) ns'

f as b = sum $ map (\(i,a) -> abs (a+b)) as