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

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

main = do
    n <- getInt
    ls <- VU.fromList <$> 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 VU.! i) (ls VU.! j) (ls VU.! k)]

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