data Monotony = Dec | Inc | Nmn deriving (Eq, Show)

monotony :: [Int] -> Monotony
monotony [a,b,c] =
    if a<b
        then if b<c
            then Inc
            else Nmn
        else if b>=c
            then Dec
            else Nmn

kanashimi b xs = aux b 0 1 xs
    where
        aux _ ac _ []     = ac
        aux b ac i (x:xs) = aux b (ac+abs(x-b-i)) (i+1) xs

range n xs = [kanashimi b xs | b <- [n-1..n+1]]


main = do
    n <- getLine
    xs <- ((fmap read . words) <$> getLine) :: IO [Int]
    print $ solve (b_ini xs) xs

b_ini :: [Int] -> Int
b_ini xs = ceiling (ave xs) - (div (length xs) 2)

solve n xs = do
    let [a,b,c] = range n xs
    case monotony [a,b,c] of
        Inc -> solve (n-1) xs
        Dec -> solve (n+1) xs
        Nmn -> b


ave :: [Int] -> Double
ave xs = fromIntegral (sum xs) / fromIntegral (length xs)