import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

judge :: [Int] -> Int -> Int
judge xs 0 = 0
judge xs n = k + judge xs (n - 1)
  where
    xs' = take n xs
    k = if minimum xs' == last xs' then 1 else 0


main = do
  n <- getInt
  ps <- getIntList
  print $ judge ps n