import Control.Monad
import Data.Function
import Data.Char
import Data.List
import Text.Read
import Text.ParserCombinators.ReadPrec

import Data.Array

newtype Pair a b = Pair { getPair :: (a, b) }

instance (Read a, Read b) => Read (Pair a b) where
  readPrec = Pair `dot` (,) <$> readPrec <* get <*> readPrec

instance (Show a, Show b) => Show (Pair a b) where
  show (Pair (a, b)) = show a ++ " " ++ show b

readPair :: IO (Int, Int)
readPair = getPair <$> readLn

infixr 8 `dot`
dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = ((.).(.))

main :: IO ()
main = do
  n <- readLn
  ls <- listArray (1, n) . map read . words <$> getLine
  print $ solve n ls

solve :: Int -> Array Int Int -> Int
solve n ls = 
  length [ (i, j, k) 
         | i <- [1..n], j <- [i+1..n], k <- [j+1..n] 
         , let [a,b,c] = sort [ls!i, ls!j, ls!k]
         , a < b && b < c
         , a + b > c
         ]
