module Main where

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

import qualified Data.Vector.Unboxed as VU

bytestr2Int = fst . fromJust . BS.readInt
getInt = bytestr2Int <$> BS.getLine
getIntL_H = map bytestr2Int. BS.words <$> BS.getLine
getIntL_V n = replicate n $ getInt
getInt2D n = replicate n $ getIntL_H

main :: IO ()
main = do
    n <- getInt
    ns <- getIntL_H
    let vecN = VU.fromList $ sort ns
    r <- sum <$> do
        forM [0..(n-3)] $ \i -> sum <$> do
            forM [(i+1)..(n-2)] $ \j ->
                pure $ check vecN (vecN VU.! i + vecN VU.! j) (j+1) n 0
    print r


check v thresh x lim r = if lim == x
    then
        r
    else if v VU.! x < thresh 
        then
            r
        else
            check v thresh (x+1) lim (r+1)
