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] = 0
solve [a,b,c] = calc [a,b,c]
solve s@(a:b:c:d) = solve2 a bs + solve bs where
  bs = tail s

solve2 :: Int -> [Int] -> Int
solve2 a [b] = 0
solve2 a [b,c] = calc [a,b,c]
solve2 a s@(b:c:d) = solve3 (abs(a-b),a+b) cs + solve2 a cs where
  cs = tail s

solve3 :: (Int,Int) -> [Int] -> Int
solve3 (mn,mx) (c:d) = (bound [mn,c,mx])?(1,0) + (null d)?(0,solve3 (mn,mx) d)

bound [a,b,c] = a<b && b<c
calc [a,b,c] = (bound[abs(a-b),c,a+b])?(1,0)
