import qualified Data.ByteString.Char8 as B
import Data.List

main = do
    n <- readLn :: IO Int
    xs <- sort . (zipWith (-)  [1..n]) . map read . words . B.unpack <$> B.getLine
    let y = xs !! (n `quot` 2)
    print $ foldl' (\a x -> a + (abs $ x-y)) 0 xs