import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M
import qualified Data.Vector.Storable as V

main=do
    n<-readLn::IO Int
    as<-sort.map (\(i,a)->a-i).zip [1..].unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine::IO[Int]
    let n = as !! (length as `div` 2)
    print $ sum $ map (\a->abs $ a-n) as
