import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Control.Monad
import Data.List
import qualified Data.Array as A
import Data.Array ((!))

main :: IO ()
main = do
    n <- read <$> getLine :: IO Integer
    ns <- A.listArray (1,n) . map (read :: String -> Integer) . words <$> getLine
            :: IO (A.Array Integer Integer)
    let ms = sort . flip map [1..n] $ \i -> (ns!i) - i
    let ls = A.listArray (1,n) ms
    print . sum $ map (\x -> x - (ls ! ((1+n) `div` 2))) ms