import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Control.Monad
import Data.List
import qualified Data.Array as A
import Data.Array ((!))

main :: IO ()
main = do
    n <- read <$> getLine :: IO Integer
    ns <- A.listArray (1,n) . map (read :: String -> Integer) . words <$> getLine
    let ms = flip map [1..n] $ \i -> (ns!i) - i
    let s = sum ms
    let b = if s==0 then 0 else (s `div` n)

    let l1 = sum . map (\x-> abs (x-b)) $ ms
    let l2 = sum . map (\x-> abs (x-b+1)) $ ms
    let l3 = sum . map (\x-> abs (x-b-1)) $ ms

    print $ minimum [l1, l2, l3]   