import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- listArray (1, n) . map (read::String -> Int) . words <$> getLine
  let diff = listArray (1, n) . sort . map (\i -> arr ! i - i) $ [1..n]
      intercept = (diff ! ((n + 2) `div` 2) + diff ! ((n + 1) `div` 2)) `div` 2
  print . sum . map (\i -> abs $ arr ! i - i - intercept) $ [1..n]
