{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readLn
	as <- zipWith (-) [ 1 .. ] <$> getList
	let
		b1 = sort as !! ( n `div` 2 )
		b2 = sort as !! ( n `div` 2 + 1 )
	print $ minimum $ map ( sum . map abs ) $ map ( \b -> map ( (-) b ) as ) [ b1, b2 ]