module Main where

import           Control.Applicative
import           Data.List



main :: IO ()
main = do
    n   <- readLn
    p_i <- map read . words <$> getLine
    let rP_i = reverse p_i
    putStrLn $ show $ solve3 n rP_i


solve3 :: Int -> [Int] -> Int
solve3 n p_i = leftBiggerThanRight p_i
  where
    leftBiggerThanRight :: [Int] -> Int
    leftBiggerThanRight [] = 0
    leftBiggerThanRight (x : xs)
        | xs == []          = 1
        | x <= (minimum xs) = 1 + (leftBiggerThanRight xs)
        | x > (minimum xs)  = 0 + (leftBiggerThanRight xs)

