import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List (tails)

combinations :: Int -> [a] -> [[a]]
combinations 0 _  = [[]]
combinations n xs = [ y:ys | y:xs' <- tails xs
                           , ys <- combinations (n-1) xs' ]

main :: IO ()
main = do
    n <- readLn :: IO Int
    l <- map (fst . fromJust . BS.readInt)
        . BS.words <$> BS.getLine :: IO [Int]
    let cmb = combinations 3 l
    -- print cmb
    print . sum $ [1 | [a,b,c] <- cmb,
        abs (b-c) < a && a < b + c ]
