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 [slv0, slv1, slv2, slv3]
  where slv0 = sum $ map (\x -> abs(x - average aList)) aList
        slv1 = sum $ map (\x -> abs(x - 1 - average aList)) aList
        slv2 = sum $ map (\x -> abs(x + 1 - average aList)) aList
        slv2 = sum $ map (\x -> abs(x + 1 - maximum aList)) aList
        slv2 = sum $ map (\x -> abs(x + 1 - minimum aList)) aList

average :: [Integer] -> Integer
average a = roundUpOn5 $ (realToFrac (sum a)) / (realToFrac (length a))

roundUpOn5 :: (RealFrac a, Integral b) => a -> b
roundUpOn5 x
  | n <= -0.5 = m - 1
  | n >= 0.5 = m + 1
  | otherwise = m
  where (m, n) = properFraction x