import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V

main = abc132b

abc132b = do
    [n] <- getIntList
    pL  <- getIntList
    let pV = V.fromList pL
    print $ count pV 0
    
count :: V.Vector Integer -> Integer -> Integer
count vec cnt
    | V.length vec < 3 = cnt
    | otherwise = let partial = V.take 3 vec
                   in if (partial V.! 0 < partial V.! 1 && partial V.! 1 < partial V.! 2) ||
                         (partial V.! 0 > partial V.! 1 && partial V.! 1 > partial V.! 2)
                         then count (V.tail vec) (cnt + 1)
                         else count (V.tail vec) cnt

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine