import Data.List
main :: IO()
main = do
  _ <- getLine
  ps <- map read . words <$> getLine
  print $ slv ps 0
 
slv :: [Integer] -> Integer -> Integer
slv p ret | (length p) < 3 = ret
          | sec == p !! 1 = slv (tail p) (ret + 1)
          | otherwise = slv (tail p) ret
  where sec = (sort (take 3 p)) !! 1