import Control.Applicative ((<$>)) import Data.Char (isSpace) import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B import Data.List (foldl', unfoldr) getL :: (ByteString -> [Int]) -> IO [Int] getL f = f <$> B.getLine readIL :: (ByteString -> Maybe (Int, ByteString)) -> (ByteString -> [Int]) readIL f = unfoldr g where g s = do (n, s') <- f s return (n, B.dropWhile isSpace s') main :: IO () main = do B.getLine as <- reverse <$> getL (readIL B.readInt) print $ foldl' f 1 as where f :: Int -> Int -> Int f acc n | acc == 1 = n | acc <= n = acc - 1 | otherwise = acc