import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort)
import qualified Data.Vector.Unboxed as VU
import Data.Bool (bool)

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  ls <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    ls' = VU.fromList . sort $ls :: VU.Vector Int
    m = VU.length ls' :: Int
    xs = do
      i <- [0..(m - 3)]
      j <- [(i + 1)..(m - 2)]
      k <- [(j + 1)..(m - 1)]
      let
        li = ls' VU.! i
        lj = ls' VU.! j
        lk = ls' VU.! k
      bool [] [()] $ li < lj && lj < lk && ls' VU.! k < ls' VU.! i + ls' VU.! j
  print . length $ xs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
