main :: IO ()
main = do
    getLine
    solve . map read . words <$> getLine >>= print

solve :: [Int] -> Int
solve []     = 0
solve (a:ls) = solve' a ls + solve ls

solve' :: Int -> [Int] -> Int
solve' _ []   = 0
solve' a (b:cs) = length [1 | c <- filter (< a + b) cs, b + c > a && c + a > b] + solve' a cs