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

main=do
    n<-readLn::IO Int
    as<-map (\(i,a)->a-i).zip [1..].unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine::IO[Int]
    let (ms,ps) = partition (<0) as
    let mm = minimum ms
    let pp = minimum ps
    --
    print $ minimum [sum $ map abs as, sum $ map (\a->abs$a-mm) as, sum $ map (\a->abs$a-pp) as]
