import Data.List

main = do
  getLine
  ps<-map read.words<$>getLine :: IO [Int]
  print $ solve ps

solve ps = length$filter id$zipWith3 f ps (tail ps) (tail$tail ps) where
  f a b c = b /= maximum[a,b,c] && b /= minimum[a,b,c]