import Data.List

main :: IO ()
main = do
  n <- readLn
  as <- map read . words <$> getLine
  let b = calcB n as
  print $ sadness n as b

calcB :: Int -> [Int] -> Int
calcB n as = median $ sort $ zipWith (-) as [1..]

median :: [Int] -> Int
median xs = go l r ys zs
  where
    (l:ys) = xs
    (r:zs) = reverse xs
    go l r [] [] = l + (r - l) `div` 2
    go l r (y:ys) (z:zs)
      | y > z = l + (r - l) `div` 2
      | otherwise = go y z ys zs

sadness :: Int -> [Int] -> Int -> Int
sadness n as b = sum 
  [ abs (a - (b + i)) | (a, i) <- zip as [1..] ]