import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import Data.List

r' :: IO [Int]
r'  = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    n <- readLn :: IO Int
    ls <- U.fromList <$> sort <$> r'
    print $
        U.ifoldr' (\i a ac ->
            ac + (U.sum $ U.map (findTri ls a) $ U.take i ls)
        ) 0 ls

findTri v a b =
    let index_a     = findR v a
        index_b     = inclusiveR
        inclusiveR  = findR v b
        exclusiveL  = findR v (abs $ a-b)
        rangeLen    = max 0 (inclusiveR - exclusiveL)
        included x  = if exclusiveL < x && x <= inclusiveR then 1 else 0
    in  rangeLen - included index_a - included index_b


findR :: U.Vector Int -> Int -> Int
findR v = findAux (<=) (0, U.length v) v

findAux :: (Int -> Int -> Bool) -> (Int,Int) -> U.Vector Int -> Int -> Int
findAux c (l,r) v t
    | l ==r = l
    | l < r = let m = (l+r) `quot` 2
            in findAux c (if v U.! m `c` t then (m+1,r) else (l,m)) v t
