quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
  let small = [a | a <-xs, a <= x]
      large = [a | a <- xs, a > x]
  in quicksort small ++ [x] ++ quicksort large

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