import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
a~>(f,x) = [a] ++ (null x)?([],f x)
half = flip div 2
aliq = ((0==).).mod

main = do
 getLine
 inputs <- readLnInt
 print $ solve inputs

solve :: [Int] -> Int
solve [a] = 0
solve (a:b) = solve2 a b + (null b)?(0,solve b)

solve2 :: Int -> [Int] -> Int
solve2 a [b] = 0
solve2 a (b:c) = solve3 (a,b) c + (null c)?(0,solve2 a c)

solve3 :: (Int,Int) -> [Int] -> Int
solve3 (a,b) (c:d) = (judge [a,b,c])?(1,0) + (null d)?(0,solve3 (a,b) d)

judge [a,b,c] = bound [abs(a-b),c,a+b]
bound [a,b,c] = a<b && b<c
