import Control.Arrow
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  n <- getInt
  xs <- getInts
  let ys = zipWith (-) xs [1..]
  let m = median ys
  print . sum . map (abs . subtract m) $ ys

getInt :: IO Int
getInt = readLn

getInts :: IO [Int]
getInts = unfoldr (BC.readInt . BC.dropWhile (== ' ')) <$> BC.getLine

median :: Ord a => [a] -> a -- O(n log n)
median xs = sort xs !! (length xs `div` 2)
