import Control.Applicative
import Control.Monad
import Data.List

import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V

main :: IO ()
main = solve <$> readLn <*> f >>= print
  where
    f = V.fromList <$> sort <$> map read <$> words <$> getLine

solve :: Int -> Vector Int -> Int
solve n v = length $ do
  i <- [0 .. n-3]
  j <- [i+1 .. n-2]
  k <- [j+1 .. n-1]
  let x = v ! i
  let y = v ! j
  let z = v ! k
  guard $ x < y && y < z && x + y > z
  return ()
