import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Maybe

main = do
  n <- fst . fromJust . BS.readInt <$> BS.getLine
  as <- sort . zipWith (\x y -> y - x) [1 ..] <$> unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let c = as !! (div n 2)
  print $ sum $ map (\x -> abs (x - c)) as