import Data.List (sort)

main :: IO ()
main = do
  n <- readLn
  as <- map read . words <$> getLine
  let bs = sort $ zipWith (-) as [1..n]
  print $ solve n bs

solve :: Int -> [Int] -> Int
solve n bs
  | odd n = bs !! ((n-1) `div` 2)
  | even n = ((bs !! ((n `div` 2) - 1)) 
    + (bs !! (n `div` 2))) `div` 2
