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

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

main = do
    n <- getInt
    ls <- getIntList
    print $ solve ls n

solve ls n = length [() | i <- [0..(n-3)], j <- [(i+1)..(n-2)], k <- [(j+1)..(n-1)], tri (ls !! i) (ls !! j) (ls !! k)]

tri a b c | a + b > c && b + c > a && c + a > b = True
          | otherwise = False