import Data.List
import qualified Data.ByteString.Char8 as BS
main=do
 n<-readLn;a<-map (read.BS.unpack).BS.words<$>BS.getLine
 print (f n (sort (map (\(i,a)->a-i) (zip [1..n] a))))
  where f n a = g a (m n a)
        m n a |odd n  = a!!(quot n 2)
              |even n = (\(x:y:s)->quot (x+y) 2) (drop ((quot n 2)-1) a)
        g a m = sum (map (\s->abs (s-m)) a)