import qualified Data.List as L
import qualified Data.Map as Map

getInts :: IO [Integer]
getInts = map read . words <$> getLine

main :: IO()
main = do
  n <- getLine
  a <- getInts
  let aList = zipWith (-) a [1..]
  putStrLn $ show $ slv aList

slv :: [Integer] -> Integer
slv aList = minimum $ map (\y -> sum $ map (\x -> abs(x - y)) aList) aListMinMax
  where aListMax = maximum aList
        aListMin = minimum aList
        aListMinMax = [aListMin..aListMax]
