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] <- getInts
  a <- getInts
  let aList = zipWith (-) a [1..]
  putStrLn $ show $ slv a aList n

slv :: [Integer] -> [Integer] -> Integer -> Integer
slv a aList n = minimum [slv0, slv1, slv2]
  where slv0 = sum $ map (\x -> abs(x - md)) aList
        slv1 = sum $ map (\x -> abs(x - 1 - md)) aList
        slv2 = sum $ map (\x -> abs(x + 1 - md)) aList
        md = median aList

median :: [Integer] -> Integer
median [] = 0
median ns =
    let l = length ns
        n = div l 2
        ms = L.sort ns
    in if mod l 2 == 0 then
        ((ms !! (n - 1)) + (ms !! n)) `div` 2
    else
        (ms !! n)
