import System.IO
import Data.List

main = do
	n <- getLine
	as <- getLine >>= fmap read . words
	putStrLn . show . head . [xs | xs <- iterate mani as, jouken n xs] 

mani [] = []
mani [a] = [a-1, a+1]
mani (a:as) = [(a-1) : x | x <- mani as] ++ [(a+1) : x | x <- mani as]

subsum xs j = sum . take j $ xs

jouken n xs = length [i | i <- [1 .. n-1], (subsum xs i) * (subsum xs (i+1)) >= 0] == 0