import Control.Applicative

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

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