import Debug.Trace

solve0 as b = sum $ zipWith (\a i->abs (a-(b+i))) as [1,2..]

solve as minB maxB
  | abs(rb - lb) < 3 = minimum $ map (solve0 as) [lb, lb+1, lb+2]
  | lbs < rbs = solve as minB rb
  | otherwise = solve as lb maxB
  where lb = (minB*2+maxB)`div`3
        rb = (minB+maxB*2)`div`3
        lbs = solve0 as lb
        rbs = solve0 as rb

main :: IO ()
main = do
  _ <- read <$> getLine :: IO Int
  as <- map read.words <$> getLine :: IO [Int]
  let maxB = maximum as
  print $ solve as (-maxB) maxB
