import Data.List


main = do
  n <- read <$> getLine :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  print $ solve as

solve :: [Int] -> Int
solve as =
  ans
  where
    as' = sort $ map (\(x,y) -> x-y) $ zip as [1..]
    ans = sadness as' $ average as'

sadness l b =
  sum $ map (\e -> abs (e-b)) l

average l =
  div s len
  where
    s = sum l
    len = length l
    