main=do
 n<-readLn;a<-map read.words<$>getLine
 print (f (map (\(i,a)->a-i) (zip [1..n] a)))
  where f a = g a (m a)
        m [a] = [a]
        m [a,b] = (\m->[m,m+1]) (quot (a+b) 2)
        m a = m (init (tail a))
        g a m = minimum (map (\l->h a l) m)
        h a l = sum (map (\s->abs (s-l)) a)