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 Int
    ns <- A.listArray (1,n) . map (fst . fromJust . B.readInt) 
        . B.words <$> B.getLine :: IO (A.Array Int Int)
    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
