import Data.List

chunksOf :: Int -> [a] -> [[a]]
chunksOf n = takeWhile (not . null) . unfoldr (return . splitAt n)

main = do
  getLine
  ps <- map read . words <$> getLine
  print (der ps)

der = _der . map fst . filter (uncurry (==)) . zip [1..] 

_der ns
  | even (length ns) = min (dsum ns) (dsum (reverse ns))
  | otherwise = min (dsum (tail ns)) (dsum (init ns)) + 1
  where
    dsum = sum . map (\[x,y] -> abs (y-x)) . chunksOf 2