module Main where

import Control.Applicative
import Control.Monad
import Data.List (sort)

knss :: [Int] -> Int -> Int
knss as b = sum $ zipWith f as [1 .. length as]
  where
    f a i = abs $ a - (b + i)

main :: IO ()
main = do
    n <- readLn
    as <- fmap read . words <$> getLine
    let bs = sort $ zipWith (\a b -> a - b) as [1 .. n]
    if odd n
        then print $ knss as (bs !! (n `div` 2))
        else do
            let m = n `div` 2
            print $ minimum
                [ knss as (bs !! (m - 1))
                , knss as (bs !! m)
                ]