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
    print $ vecN
    r <- sum <$> do
        forM [1..(n-2)] $ \i ->
            pure $ btm $ foldl (\acc j -> update acc $ check vecN (vecN VU.! i + vecN VU.! j) (top acc) n 0 ) (i+1,0,0) [0..(i-1)]
    print r


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

update :: (Int,Int,Int) -> (Int,Int) -> (Int,Int,Int)
update (_,x,s) (b,y) = (b,x+y,s+x+y)

top (t,_,_) = t
mid (_,m,_) = m
btm (_,_,b) = b
