import Data.List fork f (x,y) = (f x, f y) main = do n <- readLn as <- map read . words <$> getLine print (pyramid n as) pyramid n as = length ((ipos n as) \\ (ppos (sum as))) ipos n as = [(x,y) | x <- [0 .. n-1], y <- [0 .. (as!!x - 1)]] ppos x = last $ takeWhile ((<= x) . length) $ iterate shift [(0,0)] where shift ps = [(i,0) | i<-[0 .. (maximum (map fst ps) + 2)]] ++ map (fork succ) ps