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 -- :: IO (A.Array Int Integer)
    let ms = flip map [1..n] $ \i -> (ns!i) - i
    let m = sum ms `div` n
    -- print $ ms
    -- print $ m
    -- print $ map (\x-> x - m) ms
    print . sum $ map (\x-> abs (x - m)) ms
