import Data.List

main = do
  n <- read <$> getLine
  x <- map (read :: String -> Int) . words <$> getLine
  let y = zipWith (-) x [1..]
      b = head . drop (div n 2) $ sort y
      ans = sum [abs (t-b) | t <- y]
  putStrLn $ show ans
